home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / iconed1a / iconedit.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-24  |  109.2 KB  |  2,570 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form Editor 
  4.    Caption         =   "IconWorks Editor: 1 - [Untitled]"
  5.    ClientHeight    =   4665
  6.    ClientLeft      =   1290
  7.    ClientTop       =   1830
  8.    ClientWidth     =   6165
  9.    ClipControls    =   0   'False
  10.    BeginProperty Font 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H00FFFFFF&
  20.    Icon            =   "ICONEDIT.frx":0000
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form1"
  23.    LockControls    =   -1  'True
  24.    PaletteMode     =   1  'UseZOrder
  25.    ScaleHeight     =   311
  26.    ScaleMode       =   3  'Pixel
  27.    ScaleWidth      =   411
  28.    Begin VB.PictureBox Pic_ToolPalette 
  29.       AutoSize        =   -1  'True
  30.       BackColor       =   &H00808080&
  31.       BorderStyle     =   0  'None
  32.       DrawWidth       =   2
  33.       Height          =   3840
  34.       Left            =   0
  35.       Picture         =   "ICONEDIT.frx":030A
  36.       ScaleHeight     =   256
  37.       ScaleMode       =   3  'Pixel
  38.       ScaleWidth      =   32
  39.       TabIndex        =   0
  40.       TabStop         =   0   'False
  41.       Top             =   0
  42.       Visible         =   0   'False
  43.       Width           =   480
  44.    End
  45.    Begin VB.VScrollBar Scrl_Zoom 
  46.       Height          =   3870
  47.       HelpContextID   =   1903
  48.       LargeChange     =   32
  49.       Left            =   480
  50.       Max             =   258
  51.       Min             =   34
  52.       SmallChange     =   32
  53.       TabIndex        =   4
  54.       Tag             =   "9040"
  55.       Top             =   -15
  56.       Value           =   34
  57.       Visible         =   0   'False
  58.       Width           =   270
  59.    End
  60.    Begin VB.PictureBox Pic_Edit 
  61.       Appearance      =   0  'Flat
  62.       BackColor       =   &H000000FF&
  63.       ForeColor       =   &H80000008&
  64.       Height          =   3870
  65.       Left            =   735
  66.       ScaleHeight     =   256
  67.       ScaleMode       =   3  'Pixel
  68.       ScaleWidth      =   256
  69.       TabIndex        =   2
  70.       Tag             =   "9000"
  71.       Top             =   -30
  72.       Visible         =   0   'False
  73.       Width           =   3870
  74.       Begin VB.PictureBox Pic_Mask 
  75.          Appearance      =   0  'Flat
  76.          AutoRedraw      =   -1  'True
  77.          BackColor       =   &H00FFFFFF&
  78.          BorderStyle     =   0  'None
  79.          ForeColor       =   &H00000000&
  80.          Height          =   480
  81.          Left            =   1965
  82.          ScaleHeight     =   32
  83.          ScaleMode       =   3  'Pixel
  84.          ScaleWidth      =   32
  85.          TabIndex        =   6
  86.          TabStop         =   0   'False
  87.          Top             =   945
  88.          Visible         =   0   'False
  89.          Width           =   480
  90.       End
  91.       Begin VB.PictureBox Pic_Image 
  92.          Appearance      =   0  'Flat
  93.          AutoRedraw      =   -1  'True
  94.          BackColor       =   &H00000000&
  95.          BorderStyle     =   0  'None
  96.          ForeColor       =   &H00000000&
  97.          Height          =   480
  98.          Left            =   1380
  99.          ScaleHeight     =   32
  100.          ScaleMode       =   3  'Pixel
  101.          ScaleWidth      =   32
  102.          TabIndex        =   5
  103.          TabStop         =   0   'False
  104.          Top             =   945
  105.          Visible         =   0   'False
  106.          Width           =   480
  107.       End
  108.       Begin VB.PictureBox Pic_Grid 
  109.          Appearance      =   0  'Flat
  110.          AutoRedraw      =   -1  'True
  111.          BackColor       =   &H00FFFFFF&
  112.          BorderStyle     =   0  'None
  113.          ForeColor       =   &H00000000&
  114.          Height          =   480
  115.          Left            =   1380
  116.          ScaleHeight     =   32
  117.          ScaleMode       =   3  'Pixel
  118.          ScaleWidth      =   32
  119.          TabIndex        =   19
  120.          Top             =   1515
  121.          Visible         =   0   'False
  122.          Width           =   480
  123.       End
  124.       Begin VB.PictureBox Pic_Work 
  125.          Appearance      =   0  'Flat
  126.          AutoRedraw      =   -1  'True
  127.          AutoSize        =   -1  'True
  128.          BackColor       =   &H00000000&
  129.          BorderStyle     =   0  'None
  130.          FillStyle       =   0  'Solid
  131.          ForeColor       =   &H00000000&
  132.          Height          =   480
  133.          Left            =   1965
  134.          ScaleHeight     =   32
  135.          ScaleMode       =   3  'Pixel
  136.          ScaleWidth      =   32
  137.          TabIndex        =   14
  138.          TabStop         =   0   'False
  139.          Top             =   1515
  140.          Visible         =   0   'False
  141.          Width           =   480
  142.       End
  143.       Begin VB.PictureBox Pic_TempImage 
  144.          Appearance      =   0  'Flat
  145.          AutoRedraw      =   -1  'True
  146.          BackColor       =   &H00000000&
  147.          BorderStyle     =   0  'None
  148.          ForeColor       =   &H00000000&
  149.          Height          =   480
  150.          Left            =   1380
  151.          ScaleHeight     =   32
  152.          ScaleMode       =   3  'Pixel
  153.          ScaleWidth      =   32
  154.          TabIndex        =   15
  155.          Top             =   2085
  156.          Visible         =   0   'False
  157.          Width           =   480
  158.       End
  159.       Begin VB.PictureBox Pic_TempMask 
  160.          Appearance      =   0  'Flat
  161.          AutoRedraw      =   -1  'True
  162.          BackColor       =   &H00FFFFFF&
  163.          BorderStyle     =   0  'None
  164.          ForeColor       =   &H00000000&
  165.          Height          =   480
  166.          Left            =   1965
  167.          ScaleHeight     =   32
  168.          ScaleMode       =   3  'Pixel
  169.          ScaleWidth      =   32
  170.          TabIndex        =   16
  171.          Top             =   2085
  172.          Visible         =   0   'False
  173.          Width           =   480
  174.       End
  175.       Begin VB.PictureBox Pic_EditTemp 
  176.          Appearance      =   0  'Flat
  177.          AutoRedraw      =   -1  'True
  178.          BackColor       =   &H00FFFFFF&
  179.          ForeColor       =   &H00000000&
  180.          Height          =   480
  181.          Left            =   1680
  182.          ScaleHeight     =   30
  183.          ScaleMode       =   3  'Pixel
  184.          ScaleWidth      =   30
  185.          TabIndex        =   20
  186.          Top             =   2745
  187.          Visible         =   0   'False
  188.          Width           =   480
  189.       End
  190.    End
  191.    Begin VB.PictureBox Pic_StatusArea 
  192.       BackColor       =   &H00C0C0C0&
  193.       BeginProperty Font 
  194.          Name            =   "Courier"
  195.          Size            =   9.75
  196.          Charset         =   0
  197.          Weight          =   700
  198.          Underline       =   0   'False
  199.          Italic          =   0   'False
  200.          Strikethrough   =   0   'False
  201.       EndProperty
  202.       FontTransparent =   0   'False
  203.       ForeColor       =   &H00C0C0C0&
  204.       Height          =   4680
  205.       HelpContextID   =   1904
  206.       Left            =   4590
  207.       ScaleHeight     =   308
  208.       ScaleMode       =   3  'Pixel
  209.       ScaleWidth      =   102
  210.       TabIndex        =   7
  211.       TabStop         =   0   'False
  212.       Tag             =   "9010"
  213.       Top             =   -30
  214.       Visible         =   0   'False
  215.       Width           =   1590
  216.       Begin VB.PictureBox Pic_Icons 
  217.          Appearance      =   0  'Flat
  218.          AutoRedraw      =   -1  'True
  219.          BackColor       =   &H80000005&
  220.          BorderStyle     =   0  'None
  221.          DragIcon        =   "ICONEDIT.frx":138C
  222.          FillStyle       =   0  'Solid
  223.          ForeColor       =   &H80000008&
  224.          Height          =   480
  225.          Index           =   0
  226.          Left            =   210
  227.          Picture         =   "ICONEDIT.frx":1696
  228.          ScaleHeight     =   32
  229.          ScaleMode       =   3  'Pixel
  230.          ScaleWidth      =   32
  231.          TabIndex        =   8
  232.          TabStop         =   0   'False
  233.          Tag             =   "9130"
  234.          Top             =   180
  235.          Width           =   480
  236.       End
  237.       Begin VB.PictureBox Pic_Icons 
  238.          Appearance      =   0  'Flat
  239.          BackColor       =   &H80000005&
  240.          BorderStyle     =   0  'None
  241.          DragIcon        =   "ICONEDIT.frx":19A0
  242.          FillStyle       =   0  'Solid
  243.          ForeColor       =   &H80000008&
  244.          Height          =   480
  245.          Index           =   1
  246.          Left            =   885
  247.          Picture         =   "ICONEDIT.frx":1CAA
  248.          ScaleHeight     =   32
  249.          ScaleMode       =   3  'Pixel
  250.          ScaleWidth      =   32
  251.          TabIndex        =   9
  252.          TabStop         =   0   'False
  253.          Tag             =   "9130"
  254.          Top             =   180
  255.          Width           =   480
  256.       End
  257.       Begin VB.PictureBox Pic_Icons 
  258.          Appearance      =   0  'Flat
  259.          BackColor       =   &H80000005&
  260.          BorderStyle     =   0  'None
  261.          DragIcon        =   "ICONEDIT.frx":1FB4
  262.          FillStyle       =   0  'Solid
  263.          ForeColor       =   &H80000008&
  264.          Height          =   480
  265.          Index           =   2
  266.          Left            =   210
  267.          Picture         =   "ICONEDIT.frx":22BE
  268.          ScaleHeight     =   32
  269.          ScaleMode       =   3  'Pixel
  270.          ScaleWidth      =   32
  271.          TabIndex        =   10
  272.          TabStop         =   0   'False
  273.          Tag             =   "9130"
  274.          Top             =   840
  275.          Width           =   480
  276.       End
  277.       Begin VB.PictureBox Pic_Icons 
  278.          Appearance      =   0  'Flat
  279.          BackColor       =   &H80000005&
  280.          BorderStyle     =   0  'None
  281.          DragIcon        =   "ICONEDIT.frx":25C8
  282.          FillStyle       =   0  'Solid
  283.          ForeColor       =   &H80000008&
  284.          Height          =   480
  285.          Index           =   3
  286.          Left            =   885
  287.          Picture         =   "ICONEDIT.frx":28D2
  288.          ScaleHeight     =   32
  289.          ScaleMode       =   3  'Pixel
  290.          ScaleWidth      =   32
  291.          TabIndex        =   11
  292.          TabStop         =   0   'False
  293.          Tag             =   "9130"
  294.          Top             =   840
  295.          Width           =   480
  296.       End
  297.       Begin VB.PictureBox Pic_Icons 
  298.          Appearance      =   0  'Flat
  299.          BackColor       =   &H80000005&
  300.          BorderStyle     =   0  'None
  301.          DragIcon        =   "ICONEDIT.frx":2BDC
  302.          FillStyle       =   0  'Solid
  303.          ForeColor       =   &H80000008&
  304.          Height          =   480
  305.          Index           =   4
  306.          Left            =   210
  307.          Picture         =   "ICONEDIT.frx":2EE6
  308.          ScaleHeight     =   32
  309.          ScaleMode       =   3  'Pixel
  310.          ScaleWidth      =   32
  311.          TabIndex        =   12
  312.          TabStop         =   0   'False
  313.          Tag             =   "9130"
  314.          Top             =   1500
  315.          Width           =   480
  316.       End
  317.       Begin VB.PictureBox Pic_Icons 
  318.          Appearance      =   0  'Flat
  319.          BackColor       =   &H80000005&
  320.          BorderStyle     =   0  'None
  321.          DragIcon        =   "ICONEDIT.frx":31F0
  322.          FillStyle       =   0  'Solid
  323.          ForeColor       =   &H80000008&
  324.          Height          =   480
  325.          Index           =   5
  326.          Left            =   885
  327.          Picture         =   "ICONEDIT.frx":34FA
  328.          ScaleHeight     =   32
  329.          ScaleMode       =   3  'Pixel
  330.          ScaleWidth      =   32
  331.          TabIndex        =   13
  332.          TabStop         =   0   'False
  333.          Tag             =   "9130"
  334.          Top             =   1500
  335.          Width           =   480
  336.       End
  337.       Begin VB.PictureBox Pic_Undo 
  338.          Appearance      =   0  'Flat
  339.          BackColor       =   &H80000005&
  340.          BorderStyle     =   0  'None
  341.          DragIcon        =   "ICONEDIT.frx":3804
  342.          ForeColor       =   &H80000008&
  343.          Height          =   480
  344.          HelpContextID   =   1902
  345.          Left            =   1035
  346.          Picture         =   "ICONEDIT.frx":3B0E
  347.          ScaleHeight     =   32
  348.          ScaleMode       =   3  'Pixel
  349.          ScaleWidth      =   32
  350.          TabIndex        =   3
  351.          TabStop         =   0   'False
  352.          Tag             =   "9150"
  353.          Top             =   2505
  354.          Width           =   480
  355.       End
  356.       Begin VB.OptionButton Opt_Mouse 
  357.          BackColor       =   &H00C0C0C0&
  358.          Height          =   360
  359.          Index           =   0
  360.          Left            =   690
  361.          TabIndex        =   17
  362.          Tag             =   "9160"
  363.          Top             =   3600
  364.          Value           =   -1  'True
  365.          Width           =   195
  366.       End
  367.       Begin VB.OptionButton Opt_Mouse 
  368.          BackColor       =   &H00C0C0C0&
  369.          Height          =   360
  370.          HelpContextID   =   1901
  371.          Index           =   1
  372.          Left            =   690
  373.          TabIndex        =   1
  374.          Tag             =   "9160"
  375.          Top             =   4200
  376.          Width           =   195
  377.       End
  378.    End
  379.    Begin VB.PictureBox Pic_ColorPalette 
  380.       Height          =   810
  381.       HelpContextID   =   1905
  382.       Left            =   0
  383.       ScaleHeight     =   50
  384.       ScaleMode       =   3  'Pixel
  385.       ScaleWidth      =   303
  386.       TabIndex        =   18
  387.       TabStop         =   0   'False
  388.       Tag             =   "9030"
  389.       Top             =   3840
  390.       Visible         =   0   'False
  391.       Width           =   4605
  392.    End
  393.    Begin MSComDlg.CommonDialog CMDialog1 
  394.       Left            =   15
  395.       Top             =   4140
  396.       _ExtentX        =   847
  397.       _ExtentY        =   847
  398.       _Version        =   393216
  399.       CancelError     =   -1  'True
  400.    End
  401.    Begin VB.Menu Menu_File 
  402.       Caption         =   "&File"
  403.       HelpContextID   =   1100
  404.       Begin VB.Menu Menu_FileSelection 
  405.          Caption         =   "&New"
  406.          HelpContextID   =   1101
  407.          Index           =   0
  408.       End
  409.       Begin VB.Menu Menu_FileSelection 
  410.          Caption         =   "&Open..."
  411.          HelpContextID   =   1102
  412.          Index           =   1
  413.       End
  414.       Begin VB.Menu Menu_FileSelection 
  415.          Caption         =   "&Save"
  416.          HelpContextID   =   1103
  417.          Index           =   2
  418.          Shortcut        =   +{F12}
  419.       End
  420.       Begin VB.Menu Menu_FileSelection 
  421.          Caption         =   "Save &As..."
  422.          HelpContextID   =   1104
  423.          Index           =   3
  424.          Shortcut        =   {F12}
  425.       End
  426.       Begin VB.Menu Menu_FileSelection 
  427.          Caption         =   "-"
  428.          Index           =   4
  429.       End
  430.       Begin VB.Menu Menu_FileSelection 
  431.          Caption         =   "E&xit"
  432.          HelpContextID   =   1105
  433.          Index           =   5
  434.       End
  435.    End
  436.    Begin VB.Menu Menu_Edit 
  437.       Caption         =   "&Edit"
  438.       HelpContextID   =   1200
  439.       Begin VB.Menu Menu_EditSelection 
  440.          Caption         =   "&Undo"
  441.          HelpContextID   =   1201
  442.          Index           =   0
  443.          Shortcut        =   %{BKSP}
  444.       End
  445.       Begin VB.Menu Menu_EditSelection 
  446.          Caption         =   "-"
  447.          Index           =   1
  448.       End
  449.       Begin VB.Menu Menu_EditSelection 
  450.          Caption         =   "Cu&t"
  451.          HelpContextID   =   1202
  452.          Index           =   2
  453.          Shortcut        =   +{DEL}
  454.       End
  455.       Begin VB.Menu Menu_EditSelection 
  456.          Caption         =   "&Copy"
  457.          HelpContextID   =   1203
  458.          Index           =   3
  459.          Shortcut        =   ^{INSERT}
  460.       End
  461.       Begin VB.Menu Menu_EditSelection 
  462.          Caption         =   "&Paste"
  463.          HelpContextID   =   1204
  464.          Index           =   4
  465.          Shortcut        =   +{INSERT}
  466.       End
  467.       Begin VB.Menu Menu_EditSelection 
  468.          Caption         =   "Paste &Opaque"
  469.          HelpContextID   =   1205
  470.          Index           =   5
  471.          Shortcut        =   ^O
  472.       End
  473.       Begin VB.Menu Menu_EditSelection 
  474.          Caption         =   "&Delete"
  475.          HelpContextID   =   1206
  476.          Index           =   6
  477.          Shortcut        =   {DEL}
  478.       End
  479.       Begin VB.Menu Menu_EditSelection 
  480.          Caption         =   "&Select All"
  481.          HelpContextID   =   1207
  482.          Index           =   7
  483.          Shortcut        =   ^A
  484.       End
  485.       Begin VB.Menu Menu_EditSelection 
  486.          Caption         =   "-"
  487.          Index           =   8
  488.       End
  489.       Begin VB.Menu Menu_EditSelection 
  490.          Caption         =   "Flip &Horizontal"
  491.          HelpContextID   =   1208
  492.          Index           =   9
  493.          Shortcut        =   ^H
  494.       End
  495.       Begin VB.Menu Menu_EditSelection 
  496.          Caption         =   "Flip &Vertical"
  497.          HelpContextID   =   1209
  498.          Index           =   10
  499.          Shortcut        =   ^V
  500.       End
  501.       Begin VB.Menu Menu_EditSelection 
  502.          Caption         =   "-"
  503.          Index           =   11
  504.       End
  505.       Begin VB.Menu Menu_EditSelection 
  506.          Caption         =   "Rotate 90  &Right"
  507.          HelpContextID   =   1210
  508.          Index           =   12
  509.          Shortcut        =   ^R
  510.       End
  511.       Begin VB.Menu Menu_EditSelection 
  512.          Caption         =   "Rotate 90  &Left"
  513.          HelpContextID   =   1211
  514.          Index           =   13
  515.          Shortcut        =   ^L
  516.       End
  517.       Begin VB.Menu Menu_EditSelection 
  518.          Caption         =   "-"
  519.          Index           =   14
  520.       End
  521.       Begin VB.Menu Menu_EditSelection 
  522.          Caption         =   "&Invert"
  523.          HelpContextID   =   1212
  524.          Index           =   15
  525.          Shortcut        =   ^I
  526.       End
  527.    End
  528.    Begin VB.Menu Menu_View 
  529.       Caption         =   "&View"
  530.       HelpContextID   =   1300
  531.       Begin VB.Menu Menu_ViewSelection 
  532.          Caption         =   "&Status Area"
  533.          Checked         =   -1  'True
  534.          HelpContextID   =   1301
  535.          Index           =   0
  536.          Shortcut        =   ^S
  537.       End
  538.       Begin VB.Menu Menu_ViewSelection 
  539.          Caption         =   "&Tool Palette"
  540.          Checked         =   -1  'True
  541.          HelpContextID   =   1302
  542.          Index           =   1
  543.          Shortcut        =   ^T
  544.       End
  545.       Begin VB.Menu Menu_ViewSelection 
  546.          Caption         =   "&Color Palette"
  547.          Checked         =   -1  'True
  548.          HelpContextID   =   1303
  549.          Index           =   2
  550.          Shortcut        =   ^C
  551.       End
  552.       Begin VB.Menu Menu_ViewSelection 
  553.          Caption         =   "&Zooming Scroll bar"
  554.          Checked         =   -1  'True
  555.          HelpContextID   =   1304
  556.          Index           =   3
  557.          Shortcut        =   ^Z
  558.       End
  559.       Begin VB.Menu Menu_ViewSelection 
  560.          Caption         =   "Show &All"
  561.          HelpContextID   =   1305
  562.          Index           =   4
  563.       End
  564.       Begin VB.Menu Menu_ViewSelection 
  565.          Caption         =   "-"
  566.          Index           =   5
  567.       End
  568.       Begin VB.Menu Menu_ViewSelection 
  569.          Caption         =   "&Grid"
  570.          HelpContextID   =   1306
  571.          Index           =   6
  572.          Shortcut        =   ^G
  573.       End
  574.       Begin VB.Menu Menu_ViewSelection 
  575.          Caption         =   "&Line Grid"
  576.          HelpContextID   =   1307
  577.          Index           =   7
  578.       End
  579.       Begin VB.Menu Menu_ViewSelection 
  580.          Caption         =   "&Dotted Grid"
  581.          HelpContextID   =   1308
  582.          Index           =   8
  583.       End
  584.       Begin VB.Menu Menu_ViewSelection 
  585.          Caption         =   "-"
  586.          Index           =   9
  587.       End
  588.       Begin VB.Menu Menu_ViewSelection 
  589.          Caption         =   "Zoom &In"
  590.          HelpContextID   =   1309
  591.          Index           =   10
  592.          Shortcut        =   ^{F11}
  593.       End
  594.       Begin VB.Menu Menu_ViewSelection 
  595.          Caption         =   "Zoom &Out"
  596.          HelpContextID   =   1310
  597.          Index           =   11
  598.          Shortcut        =   ^{F12}
  599.       End
  600.       Begin VB.Menu Menu_ViewSelection 
  601.          Caption         =   "-"
  602.          Index           =   12
  603.       End
  604.       Begin VB.Menu Menu_ViewSelection 
  605.          Caption         =   "&Focus to Editor on Drag&&Drop"
  606.          Checked         =   -1  'True
  607.          HelpContextID   =   1311
  608.          Index           =   13
  609.       End
  610.       Begin VB.Menu Menu_ViewSelection 
  611.          Caption         =   "Display &Border on selected Icon"
  612.          Checked         =   -1  'True
  613.          HelpContextID   =   1312
  614.          Index           =   14
  615.       End
  616.       Begin VB.Menu Menu_ViewSelection 
  617.          Caption         =   "&Pop-up Tools menu on Form Click"
  618.          Checked         =   -1  'True
  619.          HelpContextID   =   1313
  620.          Index           =   15
  621.       End
  622.    End
  623.    Begin VB.Menu Menu_Tools 
  624.       Caption         =   "&Tools"
  625.       HelpContextID   =   1400
  626.       Begin VB.Menu Menu_ToolsSelection 
  627.          Caption         =   "&Select"
  628.          HelpContextID   =   1401
  629.          Index           =   0
  630.       End
  631.       Begin VB.Menu Menu_ToolsSelection 
  632.          Caption         =   "&Paint"
  633.          HelpContextID   =   1402
  634.          Index           =   1
  635.       End
  636.       Begin VB.Menu Menu_ToolsSelection 
  637.          Caption         =   "&Fill"
  638.          HelpContextID   =   1403
  639.          Index           =   2
  640.       End
  641.       Begin VB.Menu Menu_ToolsSelection 
  642.          Caption         =   "&Line"
  643.          HelpContextID   =   1404
  644.          Index           =   3
  645.       End
  646.       Begin VB.Menu Menu_ToolsSelection 
  647.          Caption         =   "&Square"
  648.          HelpContextID   =   1405
  649.          Index           =   4
  650.       End
  651.       Begin VB.Menu Menu_ToolsSelection 
  652.          Caption         =   "Filled S&quare"
  653.          HelpContextID   =   1406
  654.          Index           =   5
  655.       End
  656.       Begin VB.Menu Menu_ToolsSelection 
  657.          Caption         =   "&Circle"
  658.          HelpContextID   =   1407
  659.          Index           =   6
  660.       End
  661.       Begin VB.Menu Menu_ToolsSelection 
  662.          Caption         =   "Filled C&ircle"
  663.          HelpContextID   =   1408
  664.          Index           =   7
  665.       End
  666.    End
  667.    Begin VB.Menu Menu_Icons 
  668.       Caption         =   "&Icons"
  669.       HelpContextID   =   1500
  670.       Begin VB.Menu Menu_IconsSelection 
  671.          Caption         =   "&1 - [Untitled]"
  672.          Index           =   0
  673.       End
  674.       Begin VB.Menu Menu_IconsSelection 
  675.          Caption         =   "&2 - [Untitled]"
  676.          Index           =   1
  677.       End
  678.       Begin VB.Menu Menu_IconsSelection 
  679.          Caption         =   "&3 - [Untitled]"
  680.          Index           =   2
  681.       End
  682.       Begin VB.Menu Menu_IconsSelection 
  683.          Caption         =   "&4 - [Untitled]"
  684.          Index           =   3
  685.       End
  686.       Begin VB.Menu Menu_IconsSelection 
  687.          Caption         =   "&5 - [Untitled]"
  688.          Index           =   4
  689.       End
  690.       Begin VB.Menu Menu_IconsSelection 
  691.          Caption         =   "&6 - [Untitled]"
  692.          Index           =   5
  693.       End
  694.    End
  695.    Begin VB.Menu Menu_Color 
  696.       Caption         =   "&Color"
  697.       HelpContextID   =   1600
  698.       Begin VB.Menu Menu_ColorSelection 
  699.          Caption         =   "&Colors..."
  700.          HelpContextID   =   1601
  701.          Index           =   0
  702.       End
  703.       Begin VB.Menu Menu_ColorSelection 
  704.          Caption         =   "&Default Color Palette"
  705.          Checked         =   -1  'True
  706.          HelpContextID   =   1602
  707.          Index           =   1
  708.       End
  709.       Begin VB.Menu Menu_ColorSelection 
  710.          Caption         =   "S&olid Colors Only"
  711.          HelpContextID   =   1603
  712.          Index           =   2
  713.       End
  714.       Begin VB.Menu Menu_ColorSelection 
  715.          Caption         =   "I&NI File Color Palette"
  716.          HelpContextID   =   1604
  717.          Index           =   3
  718.       End
  719.       Begin VB.Menu Menu_ColorSelection 
  720.          Caption         =   "-"
  721.          Index           =   4
  722.       End
  723.       Begin VB.Menu Menu_ColorSelection 
  724.          Caption         =   "&Save Color Palette to INI file"
  725.          HelpContextID   =   1605
  726.          Index           =   5
  727.       End
  728.       Begin VB.Menu Menu_ColorSelection 
  729.          Caption         =   "-"
  730.          Index           =   6
  731.       End
  732.       Begin VB.Menu Menu_ColorSelection 
  733.          Caption         =   "&Left/Right Colors"
  734.          Checked         =   -1  'True
  735.          HelpContextID   =   1606
  736.          Index           =   7
  737.       End
  738.       Begin VB.Menu Menu_ColorSelection 
  739.          Caption         =   "Screen/&Inverse Colors"
  740.          HelpContextID   =   1607
  741.          Index           =   8
  742.       End
  743.    End
  744.    Begin VB.Menu Menu_Brush 
  745.       Caption         =   "&Brush"
  746.       HelpContextID   =   1700
  747.       Begin VB.Menu Menu_BrushSelection 
  748.          Caption         =   "&Small (1 x 1)"
  749.          Checked         =   -1  'True
  750.          HelpContextID   =   1701
  751.          Index           =   1
  752.       End
  753.       Begin VB.Menu Menu_BrushSelection 
  754.          Caption         =   "&Medium (3 x 3)"
  755.          HelpContextID   =   1702
  756.          Index           =   3
  757.       End
  758.       Begin VB.Menu Menu_BrushSelection 
  759.          Caption         =   "&Large (5 x 5)"
  760.          HelpContextID   =   1703
  761.          Index           =   5
  762.       End
  763.    End
  764.    Begin VB.Menu Menu_Help 
  765.       Caption         =   "&Help"
  766.       Begin VB.Menu Menu_HelpSelection 
  767.          Caption         =   "&Index"
  768.          Index           =   1
  769.       End
  770.       Begin VB.Menu Menu_HelpSelection 
  771.          Caption         =   "&Keyboard"
  772.          Index           =   2
  773.       End
  774.       Begin VB.Menu Menu_HelpSelection 
  775.          Caption         =   "&Commands"
  776.          Index           =   3
  777.       End
  778.       Begin VB.Menu Menu_HelpSelection 
  779.          Caption         =   "&Using Help"
  780.          Index           =   4
  781.       End
  782.       Begin VB.Menu Menu_HelpSelection 
  783.          Caption         =   "-"
  784.          Index           =   5
  785.       End
  786.       Begin VB.Menu Menu_HelpSelection 
  787.          Caption         =   "&About..."
  788.          Index           =   6
  789.       End
  790.    End
  791. Attribute VB_Name = "Editor"
  792. Attribute VB_GlobalNameSpace = False
  793. Attribute VB_Creatable = False
  794. Attribute VB_PredeclaredId = True
  795. Attribute VB_Exposed = False
  796. DefInt A-G, I-Z
  797. #If Win32 Then
  798.     DefLng H
  799. #Else
  800.     DefInt H
  801. #End If
  802. ' When the View.Grid option is selected or deselected, this routine
  803. ' performs the neccessary checking, unchecking of the Grid menu item
  804. ' and Enables or disables the Grid type menu items appropriately,
  805. ' and creates the Grid if selected.
  806. Private Sub Activate_Grid()
  807.     Menu_ViewSelection(MID_GRID).Checked = Not Menu_ViewSelection(MID_GRID).Checked
  808.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  809.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  810.     If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  811.     Magnify_Icon 0, 0, 31, 31
  812. End Sub
  813. Private Sub Adjust_Color_Palette()
  814.     ' Determine if Editor is large enough for ColorPalette
  815.     If (ScaleHeight < (Pic_ColorPalette.Height + 34)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  816.         Menu_ViewSelection(MID_COLOR_PALETTE).Checked = False
  817.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = False
  818.     Else
  819.         Menu_ViewSelection(MID_COLOR_PALETTE).Enabled = True
  820.         ' Check if the ColorPalette is selected to be displayed.
  821.         If Menu_ViewSelection(MID_COLOR_PALETTE).Checked Then
  822.             NewTop = ScaleHeight - Pic_ColorPalette.Height
  823.             NewWidth = ScaleWidth
  824.             ' Check if the StatusArea is currently displayed, since the StatusArea
  825.             ' affects the width of the ColorPalette.
  826.             If Menu_ViewSelection(MID_STATUS_BAR).Checked Then NewWidth = NewWidth - Pic_StatusArea.Width + 1
  827.             ' Reposition and Resize the ColorPalette.
  828.             Pic_ColorPalette.Move Pic_ColorPalette.Left, NewTop, NewWidth
  829.         End If
  830.     End If
  831. End Sub
  832. ' When the Editor is Resized, the the Zoom Scrollbar must be resized,
  833. ' repositioned.  This routine performs the neccessary repositioning
  834. ' for the Zoom Scrollbar.
  835. Private Sub Adjust_ScrollBar()
  836.     If Menu_ViewSelection(MID_TOOL_PALETTE).Checked Then NewLeft = Pic_ToolPalette.Width Else NewLeft = -1
  837.     NewHeight = ScaleHeight + 2 + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height
  838.     NewMax = ScaleWidth - (NewLeft - Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width) + 3 + (Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width)
  839.     ' Set the new Max value to the smaller of the NewHeight and the NewMax value.
  840.     If NewMax > NewHeight Then NewMax = NewHeight
  841.     ' We must adjust the New Max value obtained above so it is a multiple of 32.
  842.     While (NewMax - 2) Mod 32
  843.         NewMax = NewMax - 1
  844.     Wend
  845.     Scrl_Zoom.Move NewLeft, Scrl_Zoom.Top, Scrl_Zoom.Width, NewHeight
  846.     Scrl_Zoom.Max = NewMax
  847.     ' Determine if current size of the Editing area is larger than the new maximum size.
  848.     If Pic_Edit.Height > Scrl_Zoom.Max Then
  849.         Scrl_Zoom.Value = Scrl_Zoom.Max
  850.     Else
  851.         Scrl_Zoom_Change
  852.     End If
  853. End Sub
  854. ' When the Editor is Resized, the the StatusArea must be resized, and hidden if necessary
  855. Private Sub Adjust_Status_Bar()
  856.     ' Determine if Editor is large enough for StatusArea
  857.     If ((ScaleHeight < (Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT)) Or (ScaleWidth < 2 * Pic_StatusArea.Width)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  858.         Menu_ViewSelection(MID_STATUS_BAR).Checked = False
  859.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = False
  860.     Else
  861.         Menu_ViewSelection(MID_STATUS_BAR).Enabled = True
  862.         If Menu_ViewSelection(MID_STATUS_BAR).Checked Then
  863.             OldHeight = Pic_StatusArea.Height
  864.             Pic_StatusArea.Move ScaleWidth - Pic_StatusArea.Width + 1, Pic_StatusArea.Top, Pic_StatusArea.Width, ScaleHeight + 2
  865.             NewTop = Pic_StatusArea.ScaleHeight - 4.25 * Opt_Mouse(0).Height
  866.             Opt_Mouse(0).Top = NewTop + 1.25 * Opt_Mouse(0).Height
  867.             Opt_Mouse(1).Top = NewTop + 3 * Opt_Mouse(0).Height
  868.             Visibility = NewTop >= (Pic_Icons(5).Top + Pic_Icons(5).Height + 2 * HIGHLIGHT + 4)
  869.             Opt_Mouse(0).Visible = Visibility
  870.             Opt_Mouse(1).Visible = Visibility
  871.             ' Determine if there is room to display the Undo Icon
  872.             If Opt_Mouse(0).Visible Then
  873.                 Pic_Undo.Visible = NewTop >= (Pic_Undo.Top + Pic_Undo.Height)
  874.             Else
  875.                 Pic_Undo.Visible = (Pic_Undo.Top + Pic_Undo.Height) <= Pic_StatusArea.ScaleHeight
  876.             End If
  877.             ' We only want to force it to repaint if its size has changed
  878.             If OldHeight <> Pic_StatusArea.Height Then Pic_StatusArea.Refresh
  879.         End If
  880.     End If
  881. End Sub
  882. ' When the Editor is Resized, the the ToolPalette may need to be hidden.
  883. Private Sub Adjust_Tool_Palette()
  884.     If ((ScaleHeight < (Pic_ToolPalette.Height + Pic_ColorPalette.Height)) And Menu_ViewSelection(MID_COLOR_PALETTE).Checked) Or ((ScaleHeight < Pic_ToolPalette.Height) And (Not Menu_ViewSelection(MID_COLOR_PALETTE).Checked)) Then
  885.         Menu_ViewSelection(MID_TOOL_PALETTE).Checked = False
  886.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = False
  887.     Else
  888.         Menu_ViewSelection(MID_TOOL_PALETTE).Enabled = True
  889.     End If
  890. End Sub
  891. ' To make magnified pixels appear more like single pixels when working
  892. ' with the various tools, this routine is used to adjust the actual pixel
  893. ' clicked to the Center or to the Edge of the selected magnified pixel.
  894. Private Sub Adjust_X_and_Y(X As Single, Y As Single, NewX, NewY, Adjustment)
  895.     Select Case Adjustment
  896.         Case TO_CENTER
  897.             NewX = (X \ PixelSize) * PixelSize + (PixelSize \ 2)
  898.             NewY = (Y \ PixelSize) * PixelSize + (PixelSize \ 2)
  899.         Case TO_EDGE
  900.             Xpix = X \ PixelSize
  901.             Ypix = Y \ PixelSize
  902.             If (X Mod PixelSize) >= (PixelSize / 2) Then Xpix = Xpix + 1
  903.             If (Y Mod PixelSize) >= (PixelSize / 2) Then Ypix = Ypix + 1
  904.             NewX = Xpix * PixelSize
  905.             NewY = Ypix * PixelSize
  906.     End Select
  907. End Sub
  908. ' This routine is called when ever the selection is to be comitted to the Icon.
  909. Private Sub Commit_Selection(ResetFlags)
  910.     ' Erase the Rectangle highlighting the selection
  911.     If Selecting Then Draw_Selection_Rectangle
  912.     Scale_Region True, X1, Y1, X2, Y2, True
  913.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  914.     w = X2 - X1
  915.     h = Y2 - Y1
  916.     If Opaque Then
  917.         ' An exact copy of Mask and Image of the Selection are copied
  918.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, h, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  919.         R = BitBlt(Pic_Mask.hDC, X1, Y1, w, h, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCCOPY)
  920.     Else
  921.         ' Only the Foreground colors are copied.
  922.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, h, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  923.         R = BitBlt(Pic_Image.hDC, X1, Y1, w, h, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, SRCINVERT)
  924.         R = BitBlt(Pic_Mask.hDC, X1, Y1, w, h, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, SRCAND)
  925.     End If
  926.     If ResetFlags Then
  927.         Selecting = False
  928.         MovingSelection = False
  929.     End If
  930.     ' Replace the Icons current Mask and Image bitmaps with the new ones.
  931.     Update_Icon Pic_Icons(CurrentIcon)
  932. End Sub
  933. ' This routine is called either in response to an Edit.Cut or Edit.Copy
  934. Private Sub Copy_Selection_To_ClipBoard(X1, Y1, X2, Y2)
  935.     Scale_Region True, X1, Y1, X2, Y2, True
  936.     Pic_Work.Picture = LoadPicture()
  937.     Pic_Work.Move Pic_Work.Left, Pic_Work.Top, X2 - X1, Y2 - Y1
  938.     R = BitBlt(Pic_Work.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Icons(CurrentIcon).hDC, X1, Y1, SRCCOPY)
  939.     Clipboard.Clear
  940.     Clipboard.SetData Pic_Work.Image
  941. End Sub
  942. ' The Grid is drawn on a separate Picture control with a White BackGround and
  943. ' Black Foreground, and is only drawn once.  When a piece of the
  944. ' grid is to be redisplayed, the part of the Grid that corresponds
  945. ' to the area of the Icon that needs to be updated is BitBlt'd
  946. ' from the Picture of the Grid over the top of the Displayed Icon,
  947. ' Using the SCRAND raster operation.
  948. Private Sub Create_Grid()
  949.     Pic_Grid.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  950.     Pic_Grid.Cls
  951.     If Menu_ViewSelection(MID_LINE_GRID).Checked Then
  952.         For i = 1 To 31
  953.             Pic_Grid.Line (0, i * PixelSize)-(Pic_Grid.ScaleWidth, i * PixelSize)
  954.             Pic_Grid.Line (i * PixelSize, 0)-(i * PixelSize, Pic_Grid.ScaleHeight)
  955.         Next i
  956.     Else
  957.         For Y = 0 To 31
  958.             For X = 0 To 31
  959.                 Pic_Grid.PSet ((X * PixelSize) + (PixelSize \ 2), (Y * PixelSize) + (PixelSize \ 2))
  960.             Next X
  961.         Next Y
  962.     End If
  963. End Sub
  964. ' This routine is called in response to an Edit.Cut, Copy, or
  965. ' Delete menu selection.
  966. Private Sub Cut_Copy_Or_Delete_Selection(Index)
  967.     If Index = MID_DELETE Then
  968.         Scale_Region True, X1, Y1, X2, Y2, True
  969.     Else
  970.         Copy_Selection_To_ClipBoard X1, Y1, X2, Y2
  971.     End If
  972.     If Index <> MID_COPY Then
  973.         Delete_Selection_From_Icon
  974.         Selecting = False
  975.         Magnify_Icon X1, Y1, X2, Y2
  976.     End If
  977. End Sub
  978. ' This routine is called either in response to an Edit.Cut or Edit.Delete
  979. Private Sub Delete_Selection_From_Icon()
  980.     Scale_Region True, X1, Y1, X2, Y2, True
  981.     Pic_Image.Line (X1, Y1)-(X2 - 1, Y2 - 1), BLACK, BF
  982.     Pic_Mask.Line (X1, Y1)-(X2 - 1, Y2 - 1), WHITE, BF
  983.     Update_Icon Pic_Icons(CurrentIcon)
  984. End Sub
  985. ' This routine is called to display the mouse coordinates.  The
  986. ' coordinates are that of the magnified pixels, not the screen
  987. ' coordinates, thus, regardless of the magnification of the Icon,
  988. ' the coordinates will all range from 0-31.
  989. Private Sub Display_Mouse_Coordinates(Xpix, Ypix)
  990.     If (Xpix >= 0) And (Xpix <= 31) Then
  991.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * 0.25
  992.         Pic_StatusArea.Print Space$(Abs(Xpix < 10)) + Format$(Xpix);
  993.     End If
  994.     If (Ypix >= 0) And (Ypix <= 31) Then
  995.         Pic_StatusArea.CurrentX = Pic_StatusArea.ScaleWidth * 0.75
  996.         Pic_StatusArea.Print Space$(Abs(Ypix < 10)) + Format$(Ypix);
  997.     End If
  998. End Sub
  999. ' The routine is called to display
  1000. ' the Line or Box for the above tools when requested.
  1001. Private Sub Draw_Line_Or_Box()
  1002.     If CurrentTool = TID_LINE Then
  1003.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region)
  1004.     Else
  1005.         Pic_Edit.Line (X1Region, Y1Region)-(X2Region, Y2Region), , B
  1006.     End If
  1007. End Sub
  1008. ' Since Windows INItialization files only allow the writing string information,
  1009. ' the Color Palette color values are stored in 3 strings, 1 for each row of the
  1010. ' color palette.  This routine is called to extract these color values from
  1011. ' the strings and assign them to the Long Integer Color array.
  1012. Private Sub Extract_Colors_From_String(ColorString As String, FirstColor, RefreshPalette)
  1013.     N = 1
  1014.     For C = FirstColor To FirstColor + 15
  1015.         i = InStr(N, ColorString, " ")
  1016.         If i = 0 Then i = Len(ColorString) + 1
  1017.         Colors(C) = Val(Mid$(ColorString, N, i - N))
  1018.         N = i + 1
  1019.     Next C
  1020.     If RefreshPalette Then
  1021.         Display_Color_Palette Pic_ColorPalette
  1022.         If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  1023.     End If
  1024. End Sub
  1025. ' This routine performs a Surface Flood fill of the selected area
  1026. ' within the Icon when the Fill tool is in use.  The Mask color
  1027. ' of all pixels that are different is then compare to the Mask
  1028. ' color of the original starting Pixel.  If the Mask colors are the
  1029. ' same the Pixel should be changed, otherwise it is unchanged.
  1030. Private Sub Fill_Tool_MouseUp(X As Single, Y As Single, X2, Y2)
  1031. Dim MaskColor As Long, NewPixelColor As Long
  1032.     If (Abs(X) >= 0) And (Abs(X) <= Pic_Edit.ScaleWidth) And (Abs(Y) >= 0) And (Abs(Y) <= Pic_Edit.ScaleHeight) Then
  1033.         Screen.MousePointer = HOURGLASS
  1034.         Xpixel = X \ PixelSize
  1035.         Ypixel = Y \ PixelSize
  1036.         MaskColor = Pic_Mask.Point(Xpixel, Ypixel)
  1037.         Pic_Work.FillColor = Pic_Edit.ForeColor
  1038.         Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  1039.         R = ExtFloodFill(Pic_Work.hDC, Xpixel, Ypixel, Pic_Icons(CurrentIcon).Point(Xpixel, Ypixel), FLOODFILLSURFACE)
  1040.         For Ypix = 0 To 31
  1041.             For Xpix = 0 To 31
  1042.                 NewPixelColor = Pic_Work.Point(Xpix, Ypix)
  1043.                 If (Pic_Icons(CurrentIcon).Point(Xpix, Ypix) <> NewPixelColor) And (Pic_Mask.Point(Xpix, Ypix) = MaskColor) Then
  1044.                     '
  1045.                     ' Pixel was changed by the FloodFill and its Mask matched that of the
  1046.                     ' starting Pixel, so we make the change on the Icons Image and Mask
  1047.                     '
  1048.                     If Opt_Mouse(SCREEN_COLORS).Value Then NewPixelColor = Pic_Image.ForeColor
  1049.                     Pic_Image.PSet (Xpix, Ypix), NewPixelColor
  1050.                     Pic_Mask.PSet (Xpix, Ypix)
  1051.                 End If
  1052.             Next Xpix
  1053.         Next Ypix
  1054.         Screen.MousePointer = DEFAULT
  1055.         X2 = 31
  1056.         Y2 = 31
  1057.     End If
  1058. End Sub
  1059. ' This routine Flips (Mirrors) the current Selection either
  1060. ' Horizontally or Vertically.   The Windows API StretchBlt()
  1061. ' routine is used to perform the Flip operation.
  1062. Private Sub Flip_Selection(Index)
  1063.     w = X2SelectFrom - X1SelectFrom
  1064.     h = Y2SelectFrom - Y1SelectFrom
  1065.     If Index = MID_FLIP_HORIZONTAL Then
  1066.         DestX = X2SelectFrom - 1
  1067.         DestY = Y1SelectFrom
  1068.         DestWidth = -w
  1069.         DestHeight = h
  1070.     Else
  1071.         DestX = X1SelectFrom
  1072.         DestY = Y2SelectFrom - 1
  1073.         DestWidth = w
  1074.         DestHeight = -h
  1075.     End If
  1076.     R = StretchBlt(Pic_TempImage.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempImage.hDC, X1SelectFrom, Y1SelectFrom, w, h, SRCCOPY)
  1077.     R = StretchBlt(Pic_TempMask.hDC, DestX, DestY, DestWidth, DestHeight, Pic_TempMask.hDC, X1SelectFrom, Y1SelectFrom, w, h, SRCCOPY)
  1078.     R = StretchBlt(Pic_Work.hDC, DestX, DestY, DestWidth, DestHeight, Pic_Work.hDC, X1SelectFrom, Y1SelectFrom, w, h, SRCCOPY)
  1079.     Scale_Region True, X1, Y1, X2, Y2, False
  1080.     If Not MovingSelection Then Commit_Selection False
  1081.     Magnify_Icon X1, Y1, X2, Y2
  1082. End Sub
  1083. Private Sub Form_Load()
  1084.     ' Determine color mode and set Icons Image bitmap size accordingly
  1085.     ' This value, ImageSize, is used within the routines Update_Icon and
  1086.     ' Extract_Image_And_Mask within ICONWRKS.BAS
  1087.     '
  1088.     If GetDeviceCaps(hDC, BITSPIXEL) = 8 Then
  1089.         ImageSize = 1024 'bytes
  1090.     Else
  1091.         ImageSize = 512  'bytes
  1092.     End If
  1093.     ' Depending on the Video mode and video driver being used for Windows,
  1094.     ' the controls on a form might not be the same dimensions when loaded
  1095.     ' under differenct resolutions.  Since the Editor is based on a
  1096.     ' 32x32 pixel Icon, the Picture controls that are used to manipulate
  1097.     ' the icons must be set at runtime to 32x32.
  1098.     '
  1099.     ' Position and size Icon within StatusArea
  1100.     '
  1101.     Edge = (Pic_StatusArea.ScaleWidth - 64) \ 3
  1102.     For Y = 0 To 2
  1103.         For X = 0 To 1
  1104.             Pic_Icons(X + Y * 2).Move Edge + X * (32 + Edge), Edge + Y * (32 + Edge), 32, 32
  1105.         Next X
  1106.     Next Y
  1107.     Pic_Mask.Move 0, 0, 32, 32
  1108.     Pic_Image.Move 0, 0, 32, 32
  1109.     Pic_TempMask.Move 0, 0, 32, 32
  1110.     Pic_TempImage.Move 0, 0, 32, 32
  1111.     Pic_Work.Move 0, 0, 32, 32
  1112.     Pic_Grid.Move 0, 0, 32, 32
  1113.     Pic_ToolPalette.Move 0, 0, 32, 256
  1114.     Pic_Undo.Move Pic_StatusArea.ScaleWidth - 34, (Editor.Pic_Icons(5).Top + Editor.Pic_Icons(5).Height + 2.5 * HIGHLIGHT), 32, 32
  1115.     Get_INI_File_Settings
  1116.     ' Adjust size of Editor appropriately for the Video mode.
  1117.     '
  1118.     If Screen.Height = EGA_HEIGHT Then
  1119.         '
  1120.         ' EGA mode
  1121.         '
  1122.         
  1123.         NewWidth = Width
  1124.         NewHeight = Screen.Height
  1125.         NewTop = 0
  1126.     Else
  1127.         ' VGA or Better
  1128.         '
  1129.         NewWidth = Screen.Width * 0.75
  1130.         NewHeight = Screen.Height * 0.75
  1131.         NewTop = (Screen.Height - NewHeight) \ 2
  1132.     End If
  1133.     Move (Screen.Width - NewWidth) \ 2, NewTop, NewWidth, NewHeight
  1134.     ' Icon is initially displayed at full maginification
  1135.     '
  1136.     Scrl_Zoom.Value = Scrl_Zoom.Max
  1137.     ' Create Monochrome Hdc and Bitmap to be used when replace the
  1138.     ' Icons Monochrome Mask.
  1139.     '
  1140.     hDCMono = CreateCompatibleDC(hDC)
  1141.     hBMMono = CreateCompatibleBitmap(hDCMono, 32, 32)
  1142.     hBMOldMono = SelectObject(hDCMono, hBMMono)
  1143.     ' The BackColor of the Editing area picture control, Pic_Edit,
  1144.     ' is set to Red at design time just so the picture controls contained
  1145.     ' within it are visible at design time.
  1146.     '
  1147.     Pic_Edit.BackColor = WHITE
  1148.     ' Select initial tool and brushsize
  1149.     '
  1150.     CurrentTool = TID_PAINT
  1151.     BrushSize = 1
  1152.     ' Initialize Default Mouse Colors
  1153.     '
  1154.     MouseColors(0) = BLACK  'Left
  1155.     MouseColors(1) = RED    'Right
  1156.     MouseColors(2) = WHITE  'Screen
  1157.     MouseColors(3) = BLACK  'Inverse
  1158.     ' Add Accelerators that are not available from the Menu Design window
  1159.     ' to the appropriate menu items.
  1160.     '
  1161.     Menu_FileSelection(MID_EXIT).Caption = "E&xit" + A_TAB + "Alt+F4"
  1162.     'Menu_EditSelection(MID_UNDO).Caption = "&Undo" + A_TAB + "Alt+Bksp"
  1163.     'Menu_EditSelection(MID_CUT).Caption = "Cu&t" + A_TAB + "Shift+Del"
  1164.     'Menu_EditSelection(MID_COPY).Caption = "&Copy" + A_TAB + "Ctrl+Ins"
  1165.     'Menu_EditSelection(MID_PASTE).Caption = "&Paste" + A_TAB + "Shift+Ins"
  1166.     'Menu_EditSelection(MID_PASTE_OPAQUE).Caption = "Paste &Opaque" + A_TAB + "Ctrl+Shift+Ins"
  1167.     'Menu_EditSelection(MID_DELETE).Caption = "&Delete" + A_TAB + "Del"
  1168.     ' Initialize all 6 Icons filename to UNTITLED, so a File.Save opertion
  1169.     ' will react just like a File.Save As, the first time.
  1170.     '
  1171.     For i = 0 To 5
  1172.       ICONINFO(i).FileName = UNTITLED
  1173.     Next i
  1174.     EditorLoaded = True
  1175. End Sub
  1176. ' Just for an added convience when selecting tools, Clicking anywhere
  1177. ' on the Editor that is not covered by another control, will display
  1178. ' the Tools menu as a pupup menu at that location.
  1179. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1180.     ' Menu is displayed on if the left button is used.
  1181.     '
  1182.     If (Button = RIGHT_BUTTON) And Menu_ViewSelection(MID_POPUP_MENU).Checked Then
  1183.         '
  1184.         ' The X and Y coordintes passed to the TrackPopupMenu() API routine
  1185.         ' are Screen coordinates in pixels, not Form coordinates, so, the
  1186.         ' X and Y coordinates of the Mouse must be adjusted, taking into
  1187.         ' account the position of the form.  And for a little more added
  1188.         ' convience, another adjustment is made so when the menu pops up,
  1189.         ' the mouse poiner is directly over the currently selected tool.
  1190.         '
  1191.         InPixels = ScaleWidth
  1192.         ScaleMode = TWIPS
  1193.         TwipsToPixels = ScaleWidth \ InPixels
  1194.         Borders = (Width - ScaleWidth)
  1195.         TitleBarAndMenu = (Height - ScaleHeight - Borders)
  1196.         IX = X + (Left \ TwipsToPixels)
  1197.         IY = Y + (Top + TitleBarAndMenu - CurrentTool * (TitleBarAndMenu \ 2)) \ TwipsToPixels
  1198.         ScaleMode = PIXELS
  1199.         Menu_ToolsSelection(CurrentTool).Checked = True
  1200.         R = TrackPopupMenu(GetSubMenu(GetMenu(hWnd), 3), 0, IX, IY, 0, hWnd, 0)
  1201.     End If
  1202. End Sub
  1203. ' Resizing of the Editor can, depending on the new size, force any
  1204. ' of the palettes to be hidden, so all major controls must be
  1205. ' resized, repositioned and possibly hidden in reponse to resizing
  1206. ' the Editor.
  1207. Private Sub Form_Resize()
  1208. Static LastWindowState
  1209.     ' Nothing is done if the Editor is minimized.
  1210.     '
  1211.     If WindowState = MINIMIZED Then
  1212.         '
  1213.         ' Hide ColorPalette since it should not be visible while the
  1214.         ' Editor is Minimized.
  1215.         '
  1216.         If ColorPaletteLoaded Then ColorPalette.Hide
  1217.     ElseIf ScaleHeight >= 34 Then
  1218.         '
  1219.         ' Hide the Editing area while resizing other controls
  1220.         ' to prevent uneccessary repaints.
  1221.         '
  1222.         Pic_Edit.Visible = False
  1223.         ' Adjust all major controls
  1224.         '
  1225.         Adjust_Status_Bar
  1226.         Adjust_Tool_Palette
  1227.         Adjust_Color_Palette
  1228.         Adjust_ScrollBar
  1229.         ' Hide or Show the major controls, based on their corresponding View
  1230.         ' menu item Checked value, which was set within the above *Adjust*
  1231.         ' routines.
  1232.         '
  1233.         Pic_ColorPalette.Visible = Menu_ViewSelection(MID_COLOR_PALETTE).Checked
  1234.         Pic_ToolPalette.Visible = Menu_ViewSelection(MID_TOOL_PALETTE).Checked
  1235.         Pic_StatusArea.Visible = Menu_ViewSelection(MID_STATUS_BAR).Checked
  1236.         Scrl_Zoom.Visible = Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked
  1237.         
  1238.         If (LastWindowState = MINIMIZED) And ColorPaletteLoaded Then ColorPalette.Show
  1239.     End If
  1240.     LastWindowState = WindowState
  1241. End Sub
  1242. ' Editor is being terminated
  1243. Private Sub Form_Unload(Cancel As Integer)
  1244.     ' Check fo any icons that have been modified since they
  1245.     ' were last saved.
  1246.     '
  1247.     Text = ""
  1248.     For i = 0 To 5
  1249.         If ICONINFO(i).Changed Then Text = Text + "Icon #" + Right$(Menu_IconsSelection(i).Caption, Len(Menu_IconsSelection(i).Caption) - 1) + CRLF
  1250.     Next i
  1251.     If Text <> "" Then
  1252.         '
  1253.         ' One or more icons were changed, so prompt user.
  1254.         '
  1255.         Text = Text + CRLF + "The icons listed have not been saved since their last modification.  Quit anyway?"
  1256.         Cancel = MsgBox(Text, 36, "ICONS HAVE CHANGED") = MBNO
  1257.     End If
  1258.     If Not Cancel Then
  1259.         '
  1260.         ' User wants to terminate Editor, so clean up.
  1261.         '
  1262.         EditorLoaded = False
  1263.         Unload ColorPalette
  1264.         SelectObject hBMMono, hBMOldMono
  1265.         DeleteObject hBMMono
  1266.         DeleteDC hDCMono
  1267.         WinHelp hWnd, dummy$, HELP_QUIT, 0
  1268.         Save_Settings_To_INI_File
  1269.         '
  1270.         ' If Editor was started up first (Null command line or anything other than
  1271.         ' "v" or "V") then we treat it as the main Form.  So, if the Viewer is loaded,
  1272.         ' we should as the user if the Viewer should also be terminated.
  1273.         '
  1274.         If (MainForm = ICONWORKS_EDITOR) And ViewerLoaded Then
  1275.             '
  1276.             ' Editor was started first and the Viewer is loaded so ask the user
  1277.             ' if the Viewer should also be terminated.
  1278.             '
  1279.             Text = "Terminate Viewer also?"
  1280.             If MsgBox(Text, 36, "IconWorks") = MBYES Then Unload Viewer
  1281.             MainForm = ICONWORKS_VIEWER
  1282.         End If
  1283.     End If
  1284. End Sub
  1285. ' In response to a MouseDown event in the Edit area, the first thing
  1286. ' that must be done is deterine what color to use when drawing the object.
  1287. Private Sub Get_Current_Colors(Button As Integer)
  1288. Dim Index As Integer
  1289.     ' Determine which of the 4 currently selected colors to use, and
  1290.     ' assign to the Edit area's foreground color.
  1291.     Index = Opt_Mouse(SCREEN_COLORS).Value * (-2) + Button - 1
  1292.     Pic_Edit.ForeColor = MouseColors(Index)
  1293.     ' If using the Paint tool, we must use the Neaest Solid color to the selected color.
  1294.     If CurrentTool = TID_PAINT Then Pic_Edit.ForeColor = GetNearestColor(hDC, Pic_Edit.ForeColor)
  1295.     If Opt_Mouse(MOUSE_COLORS).Value Then
  1296.         Pic_Image.ForeColor = Pic_Edit.ForeColor
  1297.     Else
  1298.         Pic_Image.ForeColor = (Button = RIGHT_BUTTON) And WHITE
  1299.     End If
  1300.     Pic_Mask.ForeColor = Opt_Mouse(SCREEN_COLORS).Value And WHITE
  1301.     Pic_Image.FillColor = Pic_Image.ForeColor
  1302.     Pic_Mask.FillColor = Pic_Mask.ForeColor
  1303.     Pic_Edit.FillColor = Pic_Edit.ForeColor
  1304. End Sub
  1305. ' This routine is called to read the color value strings from
  1306. ' the IconWrks.INI file, and then have The values extracted
  1307. Private Sub Get_INI_File_Colors()
  1308.     ColorString = Space$(144)
  1309.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "1", DEFAULT_COLORS_ROW1, ColorString, Len(ColorString), INI_FILENAME)
  1310.     Extract_Colors_From_String ColorString, 0, False
  1311.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "2", DEFAULT_COLORS_ROW2, ColorString, Len(ColorString), INI_FILENAME)
  1312.     Extract_Colors_From_String ColorString, 16, False
  1313.     R = GetPrivateProfileString(APP_NAME, KEY_COLOR + "3", DEFAULT_COLORS_ROW3, ColorString, Len(ColorString), INI_FILENAME)
  1314.     Extract_Colors_From_String ColorString, 32, True
  1315. End Sub
  1316. ' This routine is called only once, which is at load time to obtain
  1317. ' all settings saved to the IconWrks.INI file.
  1318. Private Sub Get_INI_File_Settings()
  1319. Dim Index As Integer
  1320.     Menu_ViewSelection(MID_STATUS_BAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_STATUS_BAR, 1, INI_FILENAME)
  1321.     Menu_ViewSelection(MID_TOOL_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_TOOL_PALETTE, 1, INI_FILENAME)
  1322.     Menu_ViewSelection(MID_COLOR_PALETTE).Checked = -GetPrivateProfileInt(APP_NAME, KEY_COLOR_PALETTE, 1, INI_FILENAME)
  1323.     Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked = -GetPrivateProfileInt(APP_NAME, KEY_ZOOM_SCROLLBAR, 1, INI_FILENAME)
  1324.     Menu_ViewSelection(MID_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_GRID, 0, INI_FILENAME)
  1325.     Menu_ViewSelection(MID_LINE_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_LINE_GRID, 1, INI_FILENAME)
  1326.     Menu_ViewSelection(MID_DOTTED_GRID).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DOTTED_GRID, 0, INI_FILENAME)
  1327.     Menu_ViewSelection(MID_FOCUS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_FOCUS, 1, INI_FILENAME)
  1328.     Menu_ViewSelection(MID_BORDER).Checked = -GetPrivateProfileInt(APP_NAME, KEY_BORDER, 1, INI_FILENAME)
  1329.     Menu_ViewSelection(MID_POPUP_MENU).Checked = -GetPrivateProfileInt(APP_NAME, KEY_POPUP, 1, INI_FILENAME)
  1330.     ' Get all Checked Color Menu item values
  1331.     Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_DEFAULT, 1, INI_FILENAME)
  1332.     Menu_ColorSelection(MID_SOLID_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_SOLID, 0, INI_FILENAME)
  1333.     Menu_ColorSelection(MID_INI_COLORS).Checked = -GetPrivateProfileInt(APP_NAME, KEY_INI, 0, INI_FILENAME)
  1334.     ' Enable or Disable the Grid type menu items based on the Check value
  1335.     Menu_ViewSelection(MID_LINE_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1336.     Menu_ViewSelection(MID_DOTTED_GRID).Enabled = Menu_ViewSelection(MID_GRID).Checked
  1337.     ' Set initial color palette
  1338.     If Menu_ColorSelection(MID_DEFAULT_COLORS).Checked Then Index = MID_DEFAULT_COLORS
  1339.     If Menu_ColorSelection(MID_SOLID_COLORS).Checked Then Index = MID_SOLID_COLORS
  1340.     If Menu_ColorSelection(MID_INI_COLORS).Checked Then Index = MID_INI_COLORS
  1341.     Menu_ColorSelection_Click Index
  1342. End Sub
  1343. ' In response to an Edit.Invert menu item selection, this routine
  1344. ' Inverts the Colors of the selection region.  Using a DrawMode
  1345. ' of INVERSE, a filled box is drawn over the selected region, which
  1346. ' inverts the colors.
  1347. Private Sub Invert_Selection()
  1348.     Pic_TempImage.DrawMode = INVERSE
  1349.     Pic_Work.DrawMode = INVERSE
  1350.     ' Invert Selected Region.  Do not need to Invert Mask.
  1351.     Pic_TempImage.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1352.     Pic_Work.Line (X1SelectFrom, Y1SelectFrom)-(X2SelectFrom, Y2SelectFrom), , BF
  1353.     Pic_TempImage.DrawMode = COPY_PEN
  1354.     Pic_Work.DrawMode = COPY_PEN
  1355.     If MovingSelection Then Draw_Selection_Rectangle Else Commit_Selection False
  1356.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  1357. End Sub
  1358. ' Once an object, Line, Square, Filled Square, Circle, or Filled Circle
  1359. ' has been size to what the user wants, this routine is called from the
  1360. ' MouseUp event for the Editing area (Pic_Edit) to display the actual
  1361. ' object.
  1362. Private Sub Line_To_Filled_Circle_MouseUp(X1, Y1, X2, Y2)
  1363.     Pic_Image.DrawWidth = BrushSize
  1364.     Pic_Mask.DrawWidth = BrushSize
  1365.     If CurrentTool = TID_FILLED_SQUARE Or CurrentTool = TID_FILLED_CIRCLE Then
  1366.         Pic_Image.FillStyle = SOLID
  1367.         Pic_Mask.FillStyle = SOLID
  1368.     End If
  1369.     ' Scale the dimensions of the object from the Editing area down
  1370.     ' to that of the Icon, 32x32.
  1371.     Scale_Region True, X1, Y1, X2, Y2, False
  1372.     Select Case CurrentTool
  1373.         Case TID_LINE
  1374.             Pic_Image.Line (X1, Y1)-(X2, Y2)
  1375.             '
  1376.             ' Draw end-point only if BrushSize is one Pixel
  1377.             If BrushSize = 1 Then Pic_Image.PSet (X2, Y2)
  1378.             Pic_Mask.Line (X1, Y1)-(X2, Y2)
  1379.             If BrushSize = 1 Then Pic_Mask.PSet (X2, Y2)
  1380.         Case TID_SQUARE, TID_FILLED_SQUARE
  1381.             Pic_Image.Line (X1, Y1)-(X2, Y2), , B
  1382.             Pic_Mask.Line (X1, Y1)-(X2, Y2), , B
  1383.         Case TID_CIRCLE, TID_FILLED_CIRCLE
  1384.             If Valid_Circle(X1, Y1, X2, Y2) Then
  1385.                 Pic_Image.Circle (XCenter, YCenter), Radius, , , , Aspect
  1386.                 Pic_Mask.Circle (XCenter, YCenter), Radius, , , , Aspect
  1387.                 Radius = 0
  1388.             End If
  1389.     End Select
  1390.     If X1 > X2 Then Swap_Values X1, X2
  1391.     If Y1 > Y2 Then Swap_Values Y1, Y2
  1392.     Pic_Image.DrawWidth = 1
  1393.     Pic_Mask.DrawWidth = 1
  1394.     Pic_Image.FillStyle = TRANSPARENT
  1395.     Pic_Mask.FillStyle = TRANSPARENT
  1396.     ' Only the area modified is redisplayed, which is the rectangle
  1397.     ' defined by the values of X1, Y1, X2, Y2.  If the Brushsize is
  1398.     ' greater than 1 pixel, then the actual area modified is slightly
  1399.     ' larger than the this rectangle, so the values X1, Y1, X2, Y2
  1400.     ' must be adjusted to include the thickness of the Brushsize so
  1401.     ' the entire area modified is redisplayed.
  1402.     '
  1403.     If (BrushSize > 1) And (CurrentTool >= TID_LINE) Then
  1404.         Adjustment = BrushSize \ 2
  1405.         X1 = X1 - Adjustment - 1
  1406.         Y1 = Y1 - Adjustment - 1
  1407.         X2 = X2 + Adjustment + 1
  1408.         Y2 = Y2 + Adjustment + 1
  1409.     End If
  1410. End Sub
  1411. ' For the Line, Square, Filled Square, Circle, and Filled Circle Tools,
  1412. ' an Inverted resizeable version of the object is displayed in response
  1413. ' to a MouseMove.  The object is anchored at the point set by the MouseDown
  1414. ' event within the Editing area.  This routine is called to erase the
  1415. ' old object and display the new object during a MouseMove event.
  1416. Private Sub Line_To_Filled_Circle_Tool_Move(Shift As Integer, X As Single, Y As Single)
  1417. Static LastCircleGood
  1418.     ' Erase Old object
  1419.     '
  1420.     Draw_Line_Or_Box
  1421.     If (CurrentTool >= TID_CIRCLE) And LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1422.     Adjust_X_and_Y X, Y, X2Region, Y2Region, TO_CENTER
  1423.     ' Holding the Shift key down forces a perfect Square or Circle.
  1424.     ' For a line, it forces either a Horizontal, Vertical or 45 degree
  1425.     ' line to be displayed.
  1426.     '
  1427.     If Shift And SHIFT_MASK Then Make_Region_Square
  1428.     If CurrentTool >= TID_CIRCLE Then
  1429.         '
  1430.         ' When sizing a circle, a rectangle with the circle displayed
  1431.         ' within the circle is drawn.  This is done to give a better
  1432.         ' feeling that the mouse is attached to the object when sizing.
  1433.         ' The rectanle is not drawn one the mouse is released.
  1434.         '
  1435.         LastCircleGood = Valid_Circle(X1Region, Y1Region, X2Region, Y2Region)
  1436.         If LastCircleGood Then Pic_Edit.Circle (XCenter, YCenter), Radius, , , , Aspect
  1437.     End If
  1438.     ' Draw New Object
  1439.     '
  1440.     Draw_Line_Or_Box
  1441. End Sub
  1442. ' To make creating a perfect Square, Circle, or a Diagonal, Vertical,
  1443. ' or Horizontal line, the routine is called whenever the Shift key
  1444. ' is depressed in conjuction to dragging the Mouse within the Editing
  1445. ' area.  This routine adjusts the actual mouse coordinates so that
  1446. ' the displayed object is Square, or in the case of a line, Diagonal,
  1447. ' Vertical, or Horizontal.
  1448. Private Sub Make_Region_Square()
  1449.     Xside = Abs(X2Region - X1Region)
  1450.     Yside = Abs(Y2Region - Y1Region)
  1451.     If Xside > Yside Then RectSide = Xside Else RectSide = Yside
  1452.     X2Region = X1Region + RectSide * Sgn(X2Region - X1Region)
  1453.     Y2Region = Y1Region + RectSide * Sgn(Y2Region - Y1Region)
  1454. End Sub
  1455. ' Changes size of brush to either 1x1, 3x3, or 5x5, and
  1456. ' Checks the corresponding Bush menu item
  1457. Private Sub Menu_BrushSelection_Click(Index As Integer)
  1458.     Menu_BrushSelection(BrushSize).Checked = False
  1459.     Menu_BrushSelection(Index).Checked = True
  1460.     BrushSize = Index
  1461. End Sub
  1462. ' Processes all Color Menu selections.
  1463. Private Sub Menu_ColorSelection_Click(Index As Integer)
  1464.     Select Case Index
  1465.         Case MID_COLORS
  1466.             '
  1467.             ' Invoke Custom ColorPalette form
  1468.             '
  1469.             ColorIndex = 0
  1470.             ColorPalette.Show
  1471.         Case MID_DEFAULT_COLORS
  1472.             '
  1473.             ' Default color palette is the same colors as the VB colorpalette
  1474.             '
  1475.             Extract_Colors_From_String DEFAULT_COLORS_ROW1, 0, False
  1476.             Extract_Colors_From_String DEFAULT_COLORS_ROW2, 16, False
  1477.             Extract_Colors_From_String DEFAULT_COLORS_ROW3, 32, True
  1478.         
  1479.         Case MID_SOLID_COLORS
  1480.             '
  1481.             ' Solid colors are the 16 colors returned from QBColors()
  1482.             '
  1483.             Menu_ColorSelection(MID_SOLID_COLORS).Checked = True
  1484.             Show_Solid_Colors_Only
  1485.         Case MID_INI_COLORS
  1486.             '
  1487.             ' If there are Colors saved to the INI file, they will
  1488.             ' be displayed, otherwise, the Default colors will be displayed
  1489.             '
  1490.             Menu_ColorSelection(MID_INI_COLORS).Checked = True
  1491.             Get_INI_File_Colors
  1492.         Case MID_SAVE_COLORS
  1493.             Save_Colors_To_INI_File
  1494.         Case MID_LEFT_RIGHT, MID_SCREEN_INVERSE
  1495.             '
  1496.             ' Same functionality as clicking either of the Mouse Option buttons
  1497.             '
  1498.             Opt_Mouse(Index - MID_LEFT_RIGHT).Value = True
  1499.     End Select
  1500.     ' If the selection was 1 of the 3 colorpalette selections, Check
  1501.     ' the current selection, and Uncheck the previous selection.
  1502.     '
  1503.     If (Index >= MID_DEFAULT_COLORS) And (Index <= MID_INI_COLORS) Then
  1504.         Menu_ColorSelection(MID_DEFAULT_COLORS).Checked = (Index = MID_DEFAULT_COLORS)
  1505.         Menu_ColorSelection(MID_SOLID_COLORS).Checked = (Index = MID_SOLID_COLORS)
  1506.         Menu_ColorSelection(MID_INI_COLORS).Checked = (Index = MID_INI_COLORS)
  1507.     End If
  1508. End Sub
  1509. ' Prepares the Edit menus Sub menu items, by Enabling or Disabling
  1510. ' the menu items depending on whether there is a current selection
  1511. ' or if the current selection is being moved, and the current format
  1512. ' of the system ClipBoard.
  1513. Private Sub Menu_Edit_Click()
  1514.     Menu_EditSelection(MID_CUT).Enabled = Selecting And Not MovingSelection
  1515.     Menu_EditSelection(MID_COPY).Enabled = Selecting And Not MovingSelection
  1516.     Menu_EditSelection(MID_PASTE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1517.     Menu_EditSelection(MID_PASTE_OPAQUE).Enabled = Clipboard.GetFormat(CF_BITMAP)
  1518.     Menu_EditSelection(MID_DELETE).Enabled = Selecting And Not MovingSelection
  1519.     Menu_EditSelection(MID_FLIP_HORIZONTAL).Enabled = Selecting
  1520.     Menu_EditSelection(MID_FLIP_VERTICAL).Enabled = Selecting
  1521.     Menu_EditSelection(MID_ROTATE_LEFT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1522.     Menu_EditSelection(MID_ROTATE_RIGHT).Enabled = Selecting And (Not MovingSelection) And ((X2Region - X1Region) = (Y2Region - Y1Region))
  1523.     Menu_EditSelection(MID_INVERT).Enabled = Selecting
  1524. End Sub
  1525. ' Processes all Edit Menu selections.
  1526. Private Sub Menu_EditSelection_Click(Index As Integer)
  1527.     Select Case Index
  1528.         Case MID_UNDO
  1529.             UnDo_Edits
  1530.         Case MID_CUT, MID_COPY, MID_DELETE
  1531.             Cut_Copy_Or_Delete_Selection Index
  1532.             
  1533.         Case MID_PASTE, MID_PASTE_OPAQUE
  1534.             Paste_ClipBoard_Contents Index
  1535.         Case MID_SELECT_ALL
  1536.             Select_Entire_Icon
  1537.         Case MID_FLIP_HORIZONTAL, MID_FLIP_VERTICAL
  1538.             Flip_Selection Index
  1539.         Case MID_ROTATE_RIGHT, MID_ROTATE_LEFT
  1540.             Rotate_Selection Index
  1541.         Case MID_INVERT
  1542.             Invert_Selection
  1543.     End Select
  1544. End Sub
  1545. ' Processes all File Menu selections.
  1546. Private Sub Menu_FileSelection_Click(Index As Integer)
  1547.     Select Case Index
  1548.         Case MID_NEW
  1549.             Prepare_For_New_Icon
  1550.       
  1551.         Case MID_OPEN
  1552.             Viewer.Show MODELESS
  1553.         Case MID_SAVE, MID_SAVE_AS
  1554.             Save_Icon Index
  1555.         Case MID_EXIT
  1556.             Unload Editor
  1557.     End Select
  1558. End Sub
  1559. ' Processes all Help Menu selections.
  1560. Private Sub Menu_HelpSelection_Click(Index As Integer)
  1561.     If Index = MID_ABOUT Then
  1562.         AboutBox.Show MODAL
  1563.     Else
  1564.         Get_Help Index
  1565.     End If
  1566. End Sub
  1567. ' Processes all Icons Menu selections.  Same as clicking
  1568. ' one of the Icons within the StatusArea.
  1569. Private Sub Menu_IconsSelection_Click(Index As Integer)
  1570.     Pic_Icons_MouseDown Index, LEFT_BUTTON, 0, 0, 0
  1571. End Sub
  1572. ' Prepares for the Tools sub menu to be shown, by Checking
  1573. ' the currently selected tool.
  1574. Private Sub Menu_Tools_Click()
  1575.     Menu_ToolsSelection(CurrentTool).Checked = True
  1576. End Sub
  1577. ' Processes all Tools Menu selections.  Same as clicking any
  1578. ' tool within the ToolPalette
  1579. Private Sub Menu_ToolsSelection_Click(Index As Integer)
  1580.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, Index * 32
  1581. End Sub
  1582. ' Processes all View Menu selections.
  1583. Private Sub Menu_ViewSelection_Click(Index As Integer)
  1584.     Select Case Index
  1585.         Case MID_STATUS_BAR, MID_TOOL_PALETTE, MID_COLOR_PALETTE, MID_ZOOM_SCROLLBAR, MID_FOCUS, MID_BORDER, MID_POPUP_MENU
  1586.             Menu_ViewSelection(Index).Checked = Not Menu_ViewSelection(Index).Checked
  1587.             If Index = MID_BORDER Then
  1588.                 HighLight_Current_Icon
  1589.             ElseIf Index < MID_FOCUS Then
  1590.                 '
  1591.                 ' Must process a From_Resize to make the Above selection
  1592.                 ' take affect since all hiding and showing of palettes is
  1593.                 ' done within the Form_Resize event.
  1594.                 '
  1595.                 Form_Resize
  1596.             End If
  1597.         Case MID_SHOW_ALL
  1598.             For i = 0 To 3
  1599.                 Menu_ViewSelection(i).Checked = True
  1600.             Next i
  1601.             Form_Resize
  1602.         Case MID_GRID
  1603.             Activate_Grid
  1604.         Case MID_LINE_GRID, MID_DOTTED_GRID
  1605.             Select_Grid_Type Index
  1606.         Case MID_ZOOM_IN
  1607.             Scrl_Zoom.Value = Scrl_Zoom.Value + 32
  1608.         Case MID_ZOOM_OUT
  1609.             Scrl_Zoom.Value = Scrl_Zoom.Value - 32
  1610.       
  1611.     End Select
  1612.     If ((Index = MID_STATUS_BAR) Or (Index = MID_SHOW_ALL)) And Menu_ViewSelection(MID_STATUS_BAR).Checked Then Display_Color_Palette Pic_ColorPalette
  1613. End Sub
  1614. ' One of the Mouse Button Options Buttons was selected, so update
  1615. ' the corresponding Color menu items Checked value.
  1616. Private Sub Opt_Mouse_Click(Index As Integer)
  1617.     Menu_ColorSelection(MID_LEFT_RIGHT).Checked = Not (-Index)
  1618.     Menu_ColorSelection(MID_SCREEN_INVERSE).Checked = -Index
  1619. End Sub
  1620. ' The paint tools is the only tool that paints directly to the
  1621. ' Editing area during the MouseMove event.  This routine draws
  1622. ' the pixels to the Icons Image and Mask, and to the Editing area,
  1623. ' so, there is no need to redisplay the modified area of the Icon
  1624. ' in response to a MouseUp event.  However, the StatusArea Icon
  1625. ' will not display the modificatioin until a MouseUp event.
  1626. Private Sub Paint_Tool_Move(Xpix, Ypix)
  1627.                 
  1628.     ' Adjust Mouse position so it is centered within the Pixel being
  1629.     ' drawn.
  1630.     '
  1631.     Adjustment = BrushSize \ 2
  1632.     X1 = Xpix - Adjustment
  1633.     Y1 = Ypix - Adjustment
  1634.     X2 = Xpix + Adjustment
  1635.     Y2 = Ypix + Adjustment
  1636.     ' Draw pixel on Icons Image and Mask
  1637.     '
  1638.     Pic_Image.Line (X1, Y1)-(X2, Y2), , BF
  1639.     Pic_Mask.Line (X1, Y1)-(X2, Y2), , BF
  1640.     ' Draw pixel on Editing area
  1641.     '
  1642.     X2 = X2 + 1
  1643.     Y2 = Y2 + 1
  1644.     Pic_Edit.Line (X1 * PixelSize, Y1 * PixelSize)-(X2 * PixelSize - 1, Y2 * PixelSize - 1), , BF
  1645.     ' Redisplay Grid in modified area if Grid is selected.
  1646.     '
  1647.     If Menu_ViewSelection(MID_GRID).Checked Then Display_Grid (Pic_Edit.hDC), X1, Y1, X2, Y2
  1648. End Sub
  1649. ' In response to an Edit.Paste or Edit.Paste Opaque, this routine is called
  1650. ' to perform the acutal paste operation.  There are two forms of the Paste:
  1651. '   Paste Shift+Ins:  Creates a Mask from the bitmap in the clipboard
  1652. '                     based on the current Screen Color selected.  All
  1653. '                     Pixels in the Bitmap that match the Screen Color
  1654. '                     become transparent.
  1655. '   Paste Opaque Ctrl+Shift+Ins:  No mask is created from the bitmap and
  1656. '                     It is pasted as is with no Screen Color attributes.
  1657. Private Sub Paste_ClipBoard_Contents(Index)
  1658.             
  1659.     ' Get Bitmap from System Clipboard
  1660.     '
  1661.     Pic_Work.Picture = Clipboard.GetData(CF_BITMAP)
  1662.     ' Determine if Bitmap is too large to paste.  Must be 32x32 pixels or
  1663.     ' smaller.
  1664.     '
  1665.     If Pic_Work.Width <= 32 And Pic_Work.Height <= 32 Then
  1666.         '
  1667.         ' Change tool selection to SelectTool, which will allow us to
  1668.         ' move the Bitmap being pasted to anywhere within the Icon.
  1669.         '
  1670.         Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  1671.         
  1672.         Pic_TempImage.Picture = Pic_Work.Image
  1673.         Opaque = MID_PASTE - Index
  1674.         If Opaque Then
  1675.             ' An Opaque paste, so the Bitmap is pasted as is.  So we simply create
  1676.             ' a solid Black mask.
  1677.             '
  1678.             Pic_TempMask.Line (0, 0)-(Pic_TempMask.ScaleWidth, Pic_TempMask.ScaleHeight), BLACK, BF
  1679.         Else
  1680.             ' A normal paste, so a Mask must be created from the Bitmap being pasted,
  1681.             ' based on the currently selected Screen color.  The Mask is created, by
  1682.             ' BitBlt'ing the the 16-color bitmap to a mono Hdc.  All pixels in the color
  1683.             ' bitmap which are the screen color will be white in the monochrome bitmap,
  1684.             ' all others will be black.  That is why the Backcolor of the Picture control
  1685.             ' containing the bitmap is first set to the currently selected Screen color.
  1686.             ' This Monochrome bitmap is then BitBlt'd back to a 16-Color Picture control
  1687.             ' so we can easily manipulate it.
  1688.             '
  1689.             Pic_Work.BackColor = MouseColors(2)
  1690.             R = BitBlt(hDCMono, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCCOPY)
  1691.             R = BitBlt(Pic_TempMask.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, hDCMono, 0, 0, SRCCOPY)
  1692.                     
  1693.             ' Once the Mask is created, all the pixels in the Image bitmap which are of
  1694.             ' currently selected screen color must be changed to Black.  To do this we
  1695.             ' Logically AND the Mask created above with the Image bitmap.  This has the
  1696.             ' affect of turning all pixels which are not the screen color to Black, leaving
  1697.             ' screen color pixels unaffected.  We then XOR the image with this result, which
  1698.             ' gives us the desired result of all screen color pixels of the origianl
  1699.             ' bitmap going to Black, all other pixels are unaffected.
  1700.             '
  1701.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_TempMask.hDC, 0, 0, SRCAND)
  1702.             R = BitBlt(Pic_TempImage.hDC, 0, 0, Pic_Work.Width, Pic_Work.Height, Pic_Work.hDC, 0, 0, SRCINVERT)
  1703.         End If
  1704.         If (Pic_Work.Width = 32) And (Pic_Work.Height = 32) Then
  1705.             ' Bitmap Pasted is too large to allow it to be moved, so we
  1706.             ' commit the Bitmap to the Icon with out allowing it to be
  1707.             ' moved, and then redisplay the Icon.
  1708.             '
  1709.             Scale_Region False, 0, 0, 32, 32, False
  1710.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  1711.             Commit_Selection True
  1712.             Magnify_Icon 0, 0, 31, 31
  1713.         Else
  1714.             ' The Bitmap pasted can be moved, so go into Move mode by setting
  1715.             ' the appropriate flags.
  1716.             '
  1717.             Selecting = True
  1718.             
  1719.             MovingSelection = True
  1720.             ' Set the Selection Region to the size of the Bitmap pasted, in
  1721.             ' both the scale of the Icon and the Magnified Icon.
  1722.             '
  1723.             Scale_Region False, 0, 0, (Pic_Work.Width), (Pic_Work.Height), False
  1724.             Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  1725.             Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  1726.             ' Redisplay Icon.  Passing a values of 0,0,0,0 simply force the Magnify_Icon
  1727.             ' routine to magnify the pasted Bitmap over the top of the magnified Icon.
  1728.             '
  1729.             Magnify_Icon 0, 0, 0, 0
  1730.         End If
  1731.     Else
  1732.         ' Bitmap was too large to paste, so prompt the user.
  1733.         '
  1734.         Pic_Work.Picture = LoadPicture()
  1735.         MsgBox "ClipBoard image is too large:  " + Format$(Pic_Work.Width) + " x " + Format$(Pic_Work.Height) + CRLF + "Image not pasted", 16, "Error"
  1736.     End If
  1737. End Sub
  1738. ' ColorPalette operations are performed on the MouseUp event,
  1739. ' and DoubleClicking the ColorPalette invokes the Custom
  1740. ' color ColorPalette Form so a flag must be set to inform the
  1741. ' MouseUp event to invoke the Custom ColorPalette form.
  1742. Private Sub Pic_ColorPalette_DblClick()
  1743.     DoubleClicked = True
  1744. End Sub
  1745. ' Checks if Mouse Coordinates are within the ColorPalette, since the mouse
  1746. ' could have been dragged outside of the ColorPalette between the MouseDown
  1747. ' and MouseUp events, in which case the ColorPalette would still get the
  1748. ' MouseUp event with coordinates outside the actual ColorPalette which would
  1749. ' generate and error when accessing the Color Array.
  1750. Private Sub Pic_ColorPalette_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1751.     If (X >= 0) And (X <= 16) And (Y >= 0) And (Y <= 3) Then Update_Mouse_Colors Button, X, Y
  1752. End Sub
  1753. Private Sub Pic_ColorPalette_Paint()
  1754.     Display_Color_Palette Pic_ColorPalette
  1755. End Sub
  1756. ' If the Icon dropped is from the Viewer, it is loaded into the
  1757. ' currently selected Icon, otherwise nothing is done.
  1758. Private Sub Pic_Edit_DragDrop(Ctl As Control, X As Single, Y As Single)
  1759.     If Ctl.Parent.Tag <> Editor.Tag Then Load_An_Icon
  1760. End Sub
  1761. ' If the Icon being dragged is from the Viewer and it has just entered
  1762. ' or left the Edit area, invert the Edit area.
  1763. Private Sub Pic_Edit_DragOver(Ctl As Control, X As Single, Y As Single, State As Integer)
  1764.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then Invert_Control Pic_Edit
  1765. End Sub
  1766. ' A MouseDown event in the Editing area signals the beginning of a new
  1767. ' Tool operation if a tool operation is not already in progress.  All
  1768. ' preparation for the Tool operation is performed here, within the
  1769. ' MouseDown event.
  1770. Private Sub Pic_Edit_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1771.     ' Propare for Tool operation only if there is not an operation already in
  1772.     ' progress, and only one mouse button is down, Left or Right.
  1773.     '
  1774.     If (ToolInProcess = 0) And ((Button = LEFT_BUTTON) Or (Button = RIGHT_BUTTON)) Then
  1775.         '
  1776.         ' Save Button value that started Tool Operation.
  1777.         '
  1778.         ToolInProcess = Button
  1779.         Get_Current_Colors Button
  1780.         Pic_Edit.DrawStyle = SOLID
  1781.         If CurrentTool = TID_PAINT Then
  1782.             '
  1783.             ' Begin a Paint tool operation.
  1784.             '
  1785.             Pic_Edit.DrawMode = COPY_PEN
  1786.             
  1787.             ' So a pixel is drawn in repsonse to just a Click within the editing
  1788.             ' area, the MouseMove event must be called since all the actual
  1789.             ' drawing to the Editing area for the Paint Tool is done within the
  1790.             ' MouseMove event.
  1791.             '
  1792.             Pic_Edit_MouseMove Button, 0, X, Y
  1793.         ElseIf CurrentTool <> TID_FILL Then
  1794.             '
  1795.             ' Prepare for all other tools other than Fill and Paint tools.
  1796.             '
  1797.             Pic_Edit.DrawMode = INVERSE
  1798.             If CurrentTool = TID_SELECT Then Adjustment = TO_EDGE Else Adjustment = TO_CENTER
  1799.             ' Determine if a Selection is in process, the Selection can be moved,
  1800.             ' and whether the MousePointer is within the current selection.
  1801.             '
  1802.             If Selecting And Moveable And ((X >= X1Region) And (X <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region)) Then
  1803.                 '
  1804.                 ' The selection is moveable and the MousePointer is within the
  1805.                 ' selection.  So prepare for a move.
  1806.                 '
  1807.                 Adjust_X_and_Y X, Y, XMoveSelection, YMoveSelection, Adjustment
  1808.                 If Button = RIGHT_BUTTON Then Opaque = True Else Opaque = False
  1809.                 If Not MovingSelection Then
  1810.                     '
  1811.                     ' The selection has not yet been moved from its original
  1812.                     ' position, so prepare to move selection.
  1813.                     '
  1814.                     ' If the Shift key is down, then the a copy of the Selection
  1815.                     ' will be moved, otherwise the selection will be move from
  1816.                     ' its current location so its previous location must be deleted.
  1817.                     '
  1818.                     If (Shift And SHIFT_MASK) = 0 Then Delete_Selection_From_Icon
  1819.                     Draw_Selection_Rectangle
  1820.                     MovingSelection = True
  1821.                     Draw_Selection_Rectangle
  1822.                 ElseIf (Shift And SHIFT_MASK) Then
  1823.                     '
  1824.                     ' The selection has already been moved from its original
  1825.                     ' location and is being moved again.  If the Shift key is
  1826.                     ' down, make a copy of the selection at its current location
  1827.                     ' and continue the move.
  1828.                     '
  1829.                     Commit_Selection False
  1830.                     Draw_Selection_Rectangle
  1831.                 End If
  1832.             Else
  1833.                 '
  1834.                 ' No selection is in progress, or a selection is in progress
  1835.                 ' but the MousePointer is not within the current selection,
  1836.                 ' or a tool other than the Select tool is in use.
  1837.                 '
  1838.                 ' If a Selection is in progress, commit the Selection at its
  1839.                 ' current location.
  1840.                 '
  1841.                 If Selecting Then Commit_Selection True
  1842.                 ' Prepare for new Tool operation
  1843.                 '
  1844.                 Opaque = True
  1845.                 Adjust_X_and_Y X, Y, X1Region, Y1Region, Adjustment
  1846.                 X2Region = X1Region
  1847.                 Y2Region = Y1Region
  1848.             End If
  1849.         End If
  1850.     End If
  1851. End Sub
  1852. ' For all tools except for the Paint tool and Fill tool, the MouseMove
  1853. ' event is used to size the object to be drawn.  The actual object is
  1854. ' drawn within the MouseUp event based on the coodinates obtained here
  1855. ' in the MouseMove event.  The Paint tool, however, does all of its
  1856. ' actual drawing to the Editing area within the MouseMove event.  The
  1857. ' Fill tool does nothing until the MouseUp event.
  1858. Private Sub Pic_Edit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1859.     ' Calculate pixel mouse is currently over.
  1860.     '
  1861.     Xpix = X \ PixelSize
  1862.     Ypix = Y \ PixelSize
  1863.     ' The Mouse coordinates are always displayed within the StatusArea
  1864.     '
  1865.     Display_Mouse_Coordinates Xpix, Ypix
  1866.     ' Depending on the Current tool, and in the case of the Select tool,
  1867.     ' the state of the Selection, the MousePointer may change.
  1868.     '
  1869.     Set_MousePointer X, Y
  1870.     ' We only want to process the MouseMove event if the Button causing
  1871.     ' the MouseMove event is the same that started the operation.
  1872.     ' The value of the Button that started the operation is stored in
  1873.     ' the global variable ToolInProcess which is set in the MouseDown event.
  1874.     '
  1875.     If (Button = ToolInProcess) And (ToolInProcess <> 0) Then
  1876.         Select Case CurrentTool
  1877.             Case TID_SELECT
  1878.                 Select_Tool_Move Shift, X, Y
  1879.             Case TID_PAINT
  1880.                 Paint_Tool_Move Xpix, Ypix
  1881.             Case TID_LINE To TID_FILLED_CIRCLE
  1882.                 Line_To_Filled_Circle_Tool_Move Shift, X, Y
  1883.         End Select
  1884.     End If
  1885. End Sub
  1886. ' For all tools except for the Paint tool, the actual object drawn
  1887. ' is not drawn until the Mouse Button is released, which is within
  1888. ' the the edit areas MouseUp event.
  1889. Private Sub Pic_Edit_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  1890.     ' There is no operation that occurs with both mouse buttons down,
  1891.     ' so check to make sure that the MouseUp event is due to the release
  1892.     ' of the same button that started the drawing operation.  The global
  1893.     ' variable ToolInProcess holds the value of the Button.
  1894.     '
  1895.     If Button = ToolInProcess Then
  1896.         Pic_Edit.DrawMode = COPY_PEN
  1897.       
  1898.         Select Case CurrentTool
  1899.             Case TID_SELECT
  1900.                 Select_Tool_MouseUp X1, Y1, X2, Y2
  1901.             Case TID_FILL
  1902.                 Fill_Tool_MouseUp X, Y, X2, Y2
  1903.             Case TID_LINE To TID_FILLED_CIRCLE
  1904.                 Line_To_Filled_Circle_MouseUp X1, Y1, X2, Y2
  1905.         End Select
  1906.         ' The Icon needs to be updated to show the affect of the
  1907.         ' Tool operation for all tools except for the Select tool if
  1908.         ' just making a selection, since all that occurs is a Rectangle
  1909.         ' showing the selection is drawn.
  1910.         '
  1911.         If Not ((CurrentTool = TID_SELECT) And (Not MovingSelection)) Then
  1912.             Update_Icon Pic_Icons(CurrentIcon)
  1913.             '
  1914.             ' Redisplay the Icon for all tools except for the Paint tool.
  1915.             ' The paint tool draws directly on the Edit area within the
  1916.             ' MouseMove event.
  1917.             '
  1918.             If SeletedTool <> TID_PAINT Then Magnify_Icon X1, Y1, X2, Y2
  1919.         End If
  1920.         ToolInProcess = False
  1921.         ' Set enabled state of Edit Menu items.
  1922.         '
  1923.         Menu_Edit_Click
  1924.     End If
  1925. End Sub
  1926. Private Sub Pic_Edit_Paint()
  1927.     ' Repaint Edit area
  1928.     Magnify_Icon 0, 0, 31, 31
  1929. End Sub
  1930. ' If the Icon dropped is from the Viewer, it is loaded into the
  1931. ' StatusArea Icon on which is was dropped and that icon is made
  1932. ' the current Icon, otherwise nothing is done.
  1933. Private Sub Pic_Icons_DragDrop(Index As Integer, Ctl As Control, X As Single, Y As Single)
  1934.     If Ctl.Parent.Tag <> Editor.Tag Then
  1935.         CurrentIcon = Index
  1936.         Load_An_Icon
  1937.     End If
  1938. End Sub
  1939. ' If the Icon being dragged is from the Viewer and it has just entered
  1940. ' or left one of the StatusArea Icons, invert the StatusArea icon.
  1941. Private Sub Pic_Icons_DragOver(Index As Integer, Ctl As Control, X As Single, Y As Single, State As Integer)
  1942.     If (Ctl.Parent.Tag <> Editor.Tag) And (State <> OVER) Then
  1943.         Invert_Control Pic_Icons(Index)
  1944.         Pic_Icons(Index).Refresh
  1945.     End If
  1946. End Sub
  1947. ' Clicking on any of the icons within the StatusArea, makes that
  1948. ' Icon the current Icon.  If the the Icon is already the current
  1949. ' Icon, and selection currently in progress is canceled, and
  1950. ' the Icon can be dragged to test what it looks like begin dragged.
  1951. ' It cannot be dropped on anything.
  1952. Private Sub Pic_Icons_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  1953.     ' Determine if new Icon is being selected
  1954.     '
  1955.     If (Button = LEFT_BUTTON) And (Index <> CurrentIcon) Then
  1956.         '
  1957.         ' New Icon has been selected, so prepare for new Icon
  1958.         '
  1959.         Menu_IconsSelection(CurrentIcon).Checked = False
  1960.         Menu_IconsSelection(Index).Checked = True
  1961.         If Selecting Then Commit_Selection True
  1962.         CurrentIcon = Index
  1963.         Select_New_Icon
  1964.     ElseIf (Button = LEFT_BUTTON) And (Index = CurrentIcon) Then
  1965.         '
  1966.         ' The current Icon was selected.
  1967.         '
  1968.         If Selecting Then
  1969.             '
  1970.             ' A selection was in progress so cancel it.
  1971.             '
  1972.             Draw_Selection_Rectangle
  1973.             Selecting = False
  1974.             MovingSelection = False
  1975.             Scale_Region True, X1, Y1, X2, Y2, True
  1976.             Magnify_Icon X1, Y1, X2, Y2
  1977.         End If
  1978.         
  1979.         ' Set the DragIcon of the selected Icon, and begin dragging
  1980.         '
  1981.         Pic_Icons(Index).DragIcon = Pic_Icons(Index).Picture
  1982.         Pic_Icons(Index).Drag
  1983.     End If
  1984. End Sub
  1985. ' Although the StatusArea appears as though it contains many controls
  1986. ' it actually contains only 7 picture controls and 2 Option buttons.
  1987. ' The rest of the information displayed within the StatusArea is painted
  1988. ' directly onto the StatusArea.  This is done to limit the actual number
  1989. ' of controls on the Editor.  The more controls, the more System resources
  1990. ' it uses and the longer it takes to load.  It may be easier to display
  1991. ' certain data using controls, but in some cases, its benificial to not
  1992. ' use controls but display the information yourself.  The easiest controls
  1993. ' to eliminate are Labels since they usually just display text and do
  1994. ' not change throughout the life of the program, and the .Print method
  1995. ' can be used to display the text instead of a label.
  1996. Private Sub Pic_StatusArea_Paint()
  1997.     ' Calculate center of StatusArea
  1998.     '
  1999.     Middle = Pic_StatusArea.ScaleWidth \ 2
  2000.     ' Set font attributes for X & Y Mouse coodinate display
  2001.     '
  2002.     Pic_StatusArea.FontName = "MS Sans Serif"
  2003.     Pic_StatusArea.FontSize = 8.25
  2004.     Pic_StatusArea.ForeColor = BLACK
  2005.     ' Display X & Y mouse coordinate labels, "X=" and Y="
  2006.     '
  2007.     Pic_StatusArea.CurrentY = Pic_Icons(5).Top + Pic_Icons(5).Height + HIGHLIGHT + 1
  2008.     Pic_StatusArea.CurrentX = (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  2009.     Pic_StatusArea.Print "X=";
  2010.     Pic_StatusArea.CurrentX = Middle + (Middle - Pic_StatusArea.TextWidth("XXXX")) \ 2
  2011.     Pic_StatusArea.Print "Y=";
  2012.     ' If the Undo Icon is visible, display its label, "Undo to:"
  2013.     '
  2014.     If Pic_Undo.Visible Then
  2015.         Text = "Undo to:"
  2016.         Pic_StatusArea.CurrentX = (Pic_Undo.Left - Pic_StatusArea.TextWidth(Text)) \ 2
  2017.         Pic_StatusArea.CurrentY = Pic_Undo.Top + ((Pic_Undo.Height - Pic_StatusArea.TextHeight(Text)) \ 2)
  2018.         Pic_StatusArea.Print "Undo to:"
  2019.     End If
  2020.     ' If the Mouse Option buttons are visible, then display the the
  2021.     ' option button Color labels and the colors themselves.  The labels are
  2022.     ' all based on the positions of the two Option buttons, so it they
  2023.     ' are moved at design time, the labels will still be displayed
  2024.     ' correctly.
  2025.     '
  2026.     If Opt_Mouse(0).Visible Then
  2027.         '
  2028.         ' Display Mouse Butons header label within a White box with a Black
  2029.         ' outline.
  2030.         '
  2031.         Text = "Mouse Buttons"
  2032.         Y1 = Opt_Mouse(0).Top - 1.25 * Opt_Mouse(0).Height
  2033.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth, Y1 + Pic_StatusArea.TextHeight(Text)), WHITE, BF
  2034.         Pic_StatusArea.Line (0, Y1)-(Pic_StatusArea.ScaleWidth - 1, Y1 + Pic_StatusArea.TextHeight(Text)), BLACK, B
  2035.         Pic_StatusArea.CurrentX = (Pic_StatusArea.ScaleWidth - Pic_StatusArea.TextWidth(Text)) \ 2
  2036.         Pic_StatusArea.CurrentY = Y1
  2037.         Pic_StatusArea.FontTransparent = True
  2038.         Pic_StatusArea.Print Text
  2039.         Pic_StatusArea.FontBold = False
  2040.         ' Display the Mouse Button color labels, centered on either
  2041.         ' side of the Option buttons.
  2042.         '
  2043.         For i = 0 To 3
  2044.             Select Case i
  2045.                 Case 0
  2046.                     Text = "Left"
  2047.                 Case 1
  2048.                     Text = "Right"
  2049.                     Shift = Middle
  2050.                 Case 2
  2051.                     Text = "Screen"
  2052.                     Shift = 0
  2053.                 Case 3
  2054.                     Text = "Inverse"
  2055.                     Shift = Middle
  2056.             End Select
  2057.             Pic_StatusArea.CurrentX = Shift + (Middle - Pic_StatusArea.TextWidth(Text)) \ 2
  2058.             Pic_StatusArea.CurrentY = Opt_Mouse(i \ 2).Top - Pic_StatusArea.TextHeight(Text) - 1
  2059.             Pic_StatusArea.Print Text
  2060.         Next i
  2061.         ' Display the 4 color squares showing currently selected colors
  2062.         ' These could be picture controls.
  2063.         '
  2064.         Display_Mouse_Colors
  2065.     End If
  2066.     ' Set StatusArea font attributes back to that of the Mouse coordinates.
  2067.     '
  2068.     Pic_StatusArea.ForeColor = RED
  2069.     Pic_StatusArea.FontName = "Courier"
  2070.     Pic_StatusArea.FontBold = True
  2071.     Pic_StatusArea.FontTransparent = False
  2072.     HighLight_Current_Icon
  2073. End Sub
  2074. ' Performs a "Select All" opertation, just as though the Edit.Select all
  2075. ' menu item was selected.
  2076. Private Sub Pic_ToolPalette_DblClick()
  2077.     If CurrentTool = TID_SELECT Then Menu_EditSelection_Click MID_SELECT_ALL
  2078. End Sub
  2079. ' Prepare for a new tool.  The actual Tool selection is done within
  2080. ' the MouseMove event.
  2081. Private Sub Pic_ToolPalette_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2082.     ' Commit and Selection currently being moved.
  2083.     '
  2084.     If Selecting Then Commit_Selection True
  2085.     ' Commit all edits to Undo Icon
  2086.     '
  2087.     Update_Icon Pic_Undo
  2088.     ' Remove Check from current tool in Tools menu
  2089.     '
  2090.     Menu_ToolsSelection(CurrentTool).Checked = False
  2091.     ' Since the actual selection is done within the MouseMove event, and
  2092.     ' a MouseMove event does not occur until the mouse is moved within
  2093.     ' the ToolPalette, we need to call the MouseMove event, to ensure
  2094.     ' the selected tool is in fact selected, since just clicking on
  2095.     ' the ToolPalette does not generate a MouseMove event.
  2096.     '
  2097.     Pic_ToolPalette_MouseMove Button, Shift, X, Y
  2098. End Sub
  2099. ' Moving the mouse within the ToolPalette after a MouseDown event, will select
  2100. ' the tool the mouse is currently over, so you can slide up and down the palette,
  2101. ' and the tool selection will follow the mouse.
  2102. Private Sub Pic_ToolPalette_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2103.     ' Calculate selected tool.  Each tool Icon is 32 pixels high, so this
  2104.     ' is done easily by Integer dividing the Y coordinate by 32.
  2105.     '
  2106.     NewTool = Y \ 32
  2107.     ' Check to make sure the Mouse is within the Y limits of the ToolPalette
  2108.     ' and not over the currently selected tool.
  2109.     '
  2110.     If (Button <> 0) And (NewTool >= TID_SELECT) And (NewTool <= TID_FILLED_CIRCLE) And (NewTool <> CurrentTool) Then
  2111.         '
  2112.         ' UnHighlight current tool
  2113.         '
  2114.         Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2115.         ' Hightlight new tool
  2116.         '
  2117.         Pic_ToolPalette.Line (0, NewTool * 32 + 1)-(31, NewTool * 32 + 31), , BF
  2118.         CurrentTool = NewTool
  2119.     End If
  2120. End Sub
  2121. Private Sub Pic_ToolPalette_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2122.     ' Set Enabled state of all Edit menu options.
  2123.     '
  2124.     Menu_Edit_Click
  2125. End Sub
  2126. ' The ToolPalette takes care of painting itself since it contains
  2127. ' a single bitmap displaying the Tools.  However, the currently
  2128. ' selected Tool needs to be Hightlighted during the Paint event.
  2129. Private Sub Pic_ToolPalette_Paint()
  2130.     ' Clear ToolPalette to background bitmap of Tools
  2131.     '
  2132.     Pic_ToolPalette.Cls
  2133.     ' HightLight current tool.  The Drawmode of the ToolPalette is
  2134.     ' set to INVERSE, so we simply draw a filled box over the current
  2135.     ' tool.  This inverts the tool.
  2136.     '
  2137.     Pic_ToolPalette.Line (0, CurrentTool * 32 + 1)-(31, CurrentTool * 32 + 31), , BF
  2138. End Sub
  2139. ' Clicking the Undo Icon in the StatusArea is the same thing as
  2140. ' selecting the Edit.Undo menu item.
  2141. Private Sub Pic_Undo_Click()
  2142.     Menu_EditSelection_Click MID_UNDO
  2143. End Sub
  2144. ' In response to a File.New menu opertation, this routine is called,
  2145. ' to prepare creating a new Icon from scratch.
  2146. Private Sub Prepare_For_New_Icon()
  2147.     ' Determine if current Icon has changed since it was saved last and
  2148.     ' and prompt user if it has been changed and not saved.
  2149.     '
  2150.     If Ok_To_Discard_Changes() Then
  2151.         '
  2152.         ' It is ok to prepare for new Icon.
  2153.         
  2154.         ' Terminate any Selection in progress and simulate a Select all,
  2155.         ' then perform an Edit.Delete operation to clear the Icon.
  2156.         '
  2157.         Selecting = False
  2158.         MovingSelection = False
  2159.         Scale_Region False, 0, 0, 32, 32, False
  2160.         Menu_EditSelection_Click MID_DELETE
  2161.         ' Intialize the IconInfo record to default values
  2162.         '
  2163.         ICONINFO(CurrentIcon).FileName = UNTITLED
  2164.         ICONINFO(CurrentIcon).Changed = False
  2165.         ' Reset both the Icon menu and the Editors Titlebar
  2166.         '
  2167.         Menu_IconsSelection(CurrentIcon).Caption = "&" + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2168.         Caption = "IconWorks Editor: " + Format$(CurrentIcon + 1) + " - " + UNTITLED
  2169.     End If
  2170. End Sub
  2171. ' Once a Selection has been made, or an Edit.Select All or Edit.Paste
  2172. ' operation has been made, this routine is called to prepare for a
  2173. ' potential movement of the Selection.  A copy of the actual Icons
  2174. ' Mask and Image are made, and this is the Source from which the
  2175. ' Selection is display whenever the Selection is in fact moved.
  2176. Private Sub Prepare_For_Possible_Move()
  2177.               
  2178.     Pic_Work.Picture = Pic_Icons(CurrentIcon).Image
  2179.     Pic_TempImage.Picture = Pic_Image.Image
  2180.     Pic_TempMask.Picture = Pic_Mask.Image
  2181. End Sub
  2182. ' When a selection has been made and the selection is Square, it may
  2183. ' be rotated Left or Right by 90 degrees.  Cannot Rotate a selection
  2184. ' that is being moved.  This routine performs the rotation in repsonse
  2185. ' to an Edit.Rotate Left/Right menu operation.
  2186. Private Sub Rotate_Selection(Index)
  2187.     ' Rotation is not instant, so set Cursor to HourGlass
  2188.     '
  2189.     Screen.MousePointer = HOURGLASS
  2190.     ' Caculate size of Region
  2191.     '
  2192.     NumPixels = X2SelectFrom - X1SelectFrom - 1
  2193.     ' Perform rotation.  The rotation is performed by reading one pixel at
  2194.     ' a time from the source and copying it to is new location in rotated
  2195.     ' either Left or Right 90 degrees.  The Point Method reads the Pixel
  2196.     ' and the Pset method is used to write the pixel.  Both the Icons
  2197.     ' Mask and Image must be rotated.
  2198.     '
  2199.     For Y = 0 To NumPixels
  2200.         For X = 0 To NumPixels
  2201.             If Index = MID_ROTATE_RIGHT Then
  2202.                 '
  2203.                 ' Rotate Right
  2204.                 '
  2205.                 Pic_Image.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + X), Pic_TempImage.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2206.                 Pic_Mask.PSet (X2SelectFrom - Y - 1, Y1SelectFrom + X), Pic_TempMask.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2207.             Else
  2208.                 ' Rotate Left
  2209.                 '
  2210.                 Pic_Image.PSet (X1SelectFrom + Y, Y2SelectFrom - X - 1), Pic_TempImage.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2211.                 Pic_Mask.PSet (X1SelectFrom + Y, Y2SelectFrom - X - 1), Pic_TempMask.Point(X1SelectFrom + X, Y1SelectFrom + Y)
  2212.             End If
  2213.         Next X
  2214.     Next Y
  2215.     ' Replace Icons Mask and Image with new Mask and Images.
  2216.     '
  2217.     Update_Icon Pic_Icons(CurrentIcon)
  2218.     Prepare_For_Possible_Move
  2219.     ' Redisplay selected region to show rotation.
  2220.     '
  2221.     Magnify_Icon X1SelectFrom, Y1SelectFrom, (X2SelectFrom), (Y2SelectFrom)
  2222.     ' Restore Cursor
  2223.     '
  2224.     Screen.MousePointer = DEFAULT
  2225. End Sub
  2226. ' In response to a Color.Save colors to INI file menu operatioin, this
  2227. ' routine is called to write the color values to IconWrks.INI.
  2228. ' WritePrivateProfileString() will create the INI file if it does not
  2229. ' exist, and will create the KeyName if it does not exist in the INI FILE.
  2230. ' The Color values are packed into a single string, one row of colors at
  2231. ' a time, and then written to the INI file.  The colors are formated
  2232. ' into 8-byte fields separated by one space.  After this routine,
  2233. ' IconWrks.INI will contain 3 key entries of:
  2234. '   Colors Row1=16777215 14737632 ...
  2235. '   Colors Row2=12632256 04210752 ...
  2236. '   Colors Row3=08421504 00000000 ...
  2237. Private Sub Save_Colors_To_INI_File()
  2238.     For i = 0 To 2
  2239.         ColorString = ""
  2240.         For C = 0 To 15
  2241.             ColorString = ColorString + Format$(Colors(i * 16 + C), "00000000 ")
  2242.         Next C
  2243.         X = WritePrivateProfileString(APP_NAME, KEY_COLOR + Format$(i + 1), ColorString, INI_FILENAME)
  2244.     Next i
  2245. End Sub
  2246. ' In Response to a File.Save or File.Save As menu operation, this routine
  2247. ' is called to either immediately save the Icon or invoke the SaveFileDlg
  2248. ' to get a Filename to save the Icon to.  A File.Save As operation always
  2249. ' invokes the Dialog, but a File.Save will only invoke the Dialog if the
  2250. ' current icon does not yet have a name, denoted by a name of UNTITLED.
  2251. Private Sub Save_Icon(Index)
  2252.     On Error Resume Next
  2253.     Dim LongName As String
  2254.     Dim Title As String
  2255.     Dim CDPath As String
  2256.     If (Index = MID_SAVE_AS) Or (ICONINFO(CurrentIcon).FileName = UNTITLED) Then
  2257.         ' Set default filter.
  2258.         Editor.CMDialog1.Filter = "Icon Files (*.ico)|*.ico"
  2259.         ' Display Save As dialog.
  2260.         Editor.CMDialog1.FilterIndex = 1
  2261.         Editor.CMDialog1.DefaultExt = "ICO"
  2262.         If Right(ICONINFO(CurrentIcon).FullPath, 1) <> "\" Then
  2263.           Editor.CMDialog1.FileName = ICONINFO(CurrentIcon).FullPath & "\" & ICONINFO(CurrentIcon).FileName
  2264.         End If
  2265.         ' If file has not been saved yet, set common dialog's
  2266.         ' default file name to *.ico
  2267.         If ICONINFO(CurrentIcon).FileName = "[Untitled]" Then
  2268.           Editor.CMDialog1.FileName = "*.ico"
  2269.         End If
  2270.         
  2271.         Editor.CMDialog1.Action = 2
  2272.         ' Exit if user cancels the dialog.
  2273.         If Err = 32755 Then Exit Sub
  2274.         Title = Editor.CMDialog1.FileTitle
  2275.         LongName = Editor.CMDialog1.FileName
  2276.         ICONINFO(CurrentIcon).FullPath = Left(LongName, Len(LongName) - Len(Title))
  2277.         ICONINFO(CurrentIcon).FileName = Editor.CMDialog1.FileTitle
  2278.         ' Adjust for root directory.
  2279.         If Len(ICONINFO(CurrentIcon).FullPath) = 3 Then
  2280.             CDPath = ICONINFO(CurrentIcon).FullPath
  2281.         Else
  2282.             CDPath = Left(LongName, Len(LongName) - Len(Title) - 1)
  2283.         End If
  2284.         ' Change directories for the editor and the viewer.
  2285.         ChDir CDPath
  2286.         Viewer.Dir_DirectoryList.Path = CDPath
  2287.     End If
  2288.         Write_Icon_To_File (ICONINFO(CurrentIcon).FullPath), ICONINFO(CurrentIcon).FileName
  2289. End Sub
  2290. ' When the Editor is terminated, this routine is called to save all
  2291. ' configurable items of the Editor to the IconWrks.INI file.  Size
  2292. ' and Location of the Editor are not saved.
  2293. ' WritePrivateProfileString() will create the INI file and/or any
  2294. ' KeyName that does not exist.
  2295. Private Sub Save_Settings_To_INI_File()
  2296.     R = WritePrivateProfileString(APP_NAME, KEY_GRID, Format$(Abs(Menu_ViewSelection(MID_GRID).Checked)), INI_FILENAME)
  2297.     R = WritePrivateProfileString(APP_NAME, KEY_LINE_GRID, Format$(Abs(Menu_ViewSelection(MID_LINE_GRID).Checked)), INI_FILENAME)
  2298.     R = WritePrivateProfileString(APP_NAME, KEY_DOTTED_GRID, Format$(Abs(Menu_ViewSelection(MID_DOTTED_GRID).Checked)), INI_FILENAME)
  2299.     R = WritePrivateProfileString(APP_NAME, KEY_STATUS_BAR, Format$(Abs(Menu_ViewSelection(MID_STATUS_BAR).Checked)), INI_FILENAME)
  2300.     R = WritePrivateProfileString(APP_NAME, KEY_TOOL_PALETTE, Format$(Abs(Menu_ViewSelection(MID_TOOL_PALETTE).Checked)), INI_FILENAME)
  2301.     R = WritePrivateProfileString(APP_NAME, KEY_COLOR_PALETTE, Format$(Abs(Menu_ViewSelection(MID_COLOR_PALETTE).Checked)), INI_FILENAME)
  2302.     R = WritePrivateProfileString(APP_NAME, KEY_ZOOM_SCROLLBAR, Format$(Abs(Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked)), INI_FILENAME)
  2303.     R = WritePrivateProfileString(APP_NAME, KEY_FOCUS, Format$(Abs(Menu_ViewSelection(MID_FOCUS).Checked)), INI_FILENAME)
  2304.     R = WritePrivateProfileString(APP_NAME, KEY_BORDER, Format$(Abs(Menu_ViewSelection(MID_BORDER).Checked)), INI_FILENAME)
  2305.     R = WritePrivateProfileString(APP_NAME, KEY_POPUP, Format$(Abs(Menu_ViewSelection(MID_POPUP_MENU).Checked)), INI_FILENAME)
  2306.     R = WritePrivateProfileString(APP_NAME, KEY_DEFAULT, Format$(Abs(Menu_ColorSelection(MID_DEFAULT_COLORS).Checked)), INI_FILENAME)
  2307.     R = WritePrivateProfileString(APP_NAME, KEY_SOLID, Format$(Abs(Menu_ColorSelection(MID_SOLID_COLORS).Checked)), INI_FILENAME)
  2308.     R = WritePrivateProfileString(APP_NAME, KEY_INI, Format$(Abs(Menu_ColorSelection(MID_INI_COLORS).Checked)), INI_FILENAME)
  2309. End Sub
  2310. ' Scrolling the Zoom scrollbar Zooms in or Zooms out on the
  2311. ' selected Icon, and maintains it centered within the available
  2312. ' editing space.
  2313. Private Sub Scrl_Zoom_Change()
  2314.     ' Check if new value is multiple of 32 pixels.  Magnified Icon must
  2315.     ' always be increased or decreased my muliples of 32 pixels so the
  2316.     ' Win API routine StretchBlt() can be used to magnify the Icon, and
  2317.     ' the result will be an exact enlargement of the original.
  2318.     '
  2319.     If (Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width Then
  2320.         '
  2321.         ' Scrollbar value is not a multiple of 32, so adjust it so it is.
  2322.         '
  2323.         Scrl_Zoom.Value = Scrl_Zoom.Value - ((Scrl_Zoom.Value - 2) Mod Pic_Icons(0).Width)
  2324.     Else
  2325.         ' Scrollbar value is a multiple of 32 pixels.
  2326.         '
  2327.         ' Hide Edit area while resizing and repainting.  It prevents a
  2328.         ' rather annoying visual affect.
  2329.         '
  2330.         Pic_Edit.Visible = False
  2331.         ' Calculate the new size and position values for the Editing area
  2332.         ' and then reposition and resize both the Editing area and the
  2333.         ' temporary Editing area which is used when magnifying the Icon.
  2334.         '
  2335.         MaxLeft = Scrl_Zoom.Left - (Menu_ViewSelection(MID_ZOOM_SCROLLBAR).Checked * Scrl_Zoom.Width)
  2336.         NewLeft = MaxLeft + (ScaleWidth + Menu_ViewSelection(MID_STATUS_BAR).Checked * Pic_StatusArea.Width - MaxLeft - Scrl_Zoom.Value) \ 2
  2337.         NewTop = (ScaleHeight + Menu_ViewSelection(MID_COLOR_PALETTE).Checked * Pic_ColorPalette.Height - Scrl_Zoom.Value) \ 2
  2338.         Pic_Edit.Move NewLeft, NewTop, Scrl_Zoom.Value, Scrl_Zoom.Value
  2339.         Pic_EditTemp.Move 0, 0, Scrl_Zoom.Value, Scrl_Zoom.Value
  2340.         ' To allow a selection to be maintained if the Zoom scrollbar is scrolled
  2341.         ' while a selection is in progress, the current selection must be scaled
  2342.         ' down to the scale of the actual Icon, the new PixelSize for the Editing
  2343.         ' area must be calculated, and then the selection is Scaled back to the
  2344.         ' new scale of the Editing area.
  2345.         '
  2346.         If Selecting Then Scale_Region True, X1Region, Y1Region, X2Region, Y2Region, False
  2347.         PixelSize = Pic_Edit.ScaleWidth \ 32
  2348.         If Selecting Then Scale_Region False, X1Region, Y1Region, X2Region, Y2Region, False
  2349.         ' Recreate grid if selected and redisplay the Editing area.
  2350.         '
  2351.         If Menu_ViewSelection(MID_GRID).Checked Then Create_Grid
  2352.         Pic_Edit.Visible = True
  2353.         ' Set enable state of Zoom in/out View menu items based on new value
  2354.         ' of the Zoom Scrollbar.
  2355.         '
  2356.         Menu_ViewSelection(MID_ZOOM_IN).Enabled = Scrl_Zoom.Value < Scrl_Zoom.Max
  2357.         Menu_ViewSelection(MID_ZOOM_OUT).Enabled = Scrl_Zoom.Value > Scrl_Zoom.Min
  2358.     End If
  2359. End Sub
  2360. ' In response to Double Clicking the Select tool, or an Edit.Select All
  2361. ' menu operation, this routine is called to perform a selection on the
  2362. ' entire Icon, which is the same as if the Entire icon was selected using
  2363. ' the mouse.
  2364. Private Sub Select_Entire_Icon()
  2365.     ' Make the select to the selected tool.  This is neccessary since
  2366.     ' this routine could have been called due to a menu selection, and
  2367.     ' the current tool may not be the Select Tool.
  2368.     '
  2369.     Pic_ToolPalette_MouseDown LEFT_BUTTON, 0, 0, TID_SELECT * 32
  2370.     ' Make all preparations for a selection just as if it was done
  2371.     ' using the mouse.
  2372.     '
  2373.     Prepare_For_Possible_Move
  2374.     Selecting = True
  2375.     Opaque = True
  2376.     Scale_Region False, 0, 0, 32, 32, False
  2377.     Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, False
  2378.     Draw_Selection_Rectangle
  2379. End Sub
  2380. ' There are two type of grids to choose from when the Grid selection
  2381. ' is active. Line and Dotted grid.  This routine is called in response
  2382. ' to a View.Line Grid or View.Dotted Grid menu operation, to set and
  2383. ' display the selected grid type.  The actual Grid is created in the
  2384. ' Create_Grid procedure.
  2385. Private Sub Select_Grid_Type(Index)
  2386.     ' Check if selected Grid is already the currently selected grid type,
  2387.     ' since there is no need to redisplay it.
  2388.     '
  2389.     If Not Menu_ViewSelection(Index).Checked Then
  2390.         '
  2391.         ' Toggle Checks on Grid type menu items.
  2392.         '
  2393.         Menu_ViewSelection(MID_LINE_GRID).Checked = Not Menu_ViewSelection(MID_LINE_GRID).Checked
  2394.         Menu_ViewSelection(MID_DOTTED_GRID).Checked = Not Menu_ViewSelection(MID_DOTTED_GRID).Checked
  2395.         ' Create the new Grid and redisplay Icon with new Grid.
  2396.         '
  2397.         Create_Grid
  2398.         Magnify_Icon 0, 0, 31, 31
  2399.     End If
  2400. End Sub
  2401. Private Sub Select_Tool_MouseUp(X1, Y1, X2, Y2)
  2402.             
  2403.     ' Erase old Selection rectangle
  2404.     '
  2405.     Draw_Selection_Rectangle
  2406.     ' Adjust selection rectangle so it is completely within the
  2407.     ' editing area.
  2408.     '
  2409.     If X1Region > X2Region Then Swap_Values X1Region, X2Region
  2410.     If Y1Region > Y2Region Then Swap_Values Y1Region, Y2Region
  2411.     If X1Region < 0 Then X1Region = 0
  2412.     If Y1Region < 0 Then Y1Region = 0
  2413.     MaxSize = PixelSize * 32
  2414.     If X2Region > MaxSize Then X2Region = MaxSize
  2415.     If Y2Region > MaxSize Then Y2Region = MaxSize
  2416.     If MovingSelection Then
  2417.         '
  2418.         ' The selection is being moved, so all that needs to be done is
  2419.         ' to update the values containing the last location of the
  2420.         ' selection, which are used when the selection is moved.
  2421.         '
  2422.         X1 = LastX1
  2423.         Y1 = LastY1
  2424.         X2 = LastX2
  2425.         Y2 = LastY2
  2426.     ElseIf (X1Region <> X2Region) And (Y1Region <> Y2Region) Then
  2427.         '
  2428.         ' A new selection has been made
  2429.         '
  2430.         Prepare_For_Possible_Move
  2431.         Selecting = True
  2432.         Opaque = True
  2433.         ' Determine if selection can be moved.  The selection cannot be moved
  2434.         ' if it consists of the entire icon.
  2435.         '
  2436.        
  2437.         Draw_Selection_Rectangle
  2438.         Scale_Region True, X1SelectFrom, Y1SelectFrom, X2SelectFrom, Y2SelectFrom, True
  2439.     End If
  2440.     Scale_Region True, LastX1, LastY1, LastX2, LastY2, True
  2441. End Sub
  2442. ' A move event using the Select tool, can do one of three things,
  2443. ' size the selection rectangle to make the selection, move the
  2444. ' current selection, or copy the current selection to another
  2445. ' location.  This routine either draws the selection rectangle
  2446. ' as the selection is being made or moves/copies the current
  2447. ' selection.
  2448. Private Sub Select_Tool_Move(Shift As Integer, X As Single, Y As Single)
  2449.     ' Erase old selection rectangle
  2450.     '
  2451.     Draw_Selection_Rectangle
  2452.     If MovingSelection Then
  2453.         '
  2454.         ' Calculate new location of Selection rectangle.
  2455.         '
  2456.         XLastMove = XMoveSelection
  2457.         YLastMove = YMoveSelection
  2458.         Adjust_X_and_Y X, Y, XMoveSelection, YMoveSelection, TO_EDGE
  2459.         X1Region = X1Region + (XMoveSelection - XLastMove)
  2460.         X2Region = X2Region + (XMoveSelection - XLastMove)
  2461.         Y1Region = Y1Region + (YMoveSelection - YLastMove)
  2462.         Y2Region = Y2Region + (YMoveSelection - YLastMove)
  2463.         ' Prevent Selection from being moved of the left or right
  2464.         ' of the editing area
  2465.         '
  2466.         If (X1Region < 0) Or (X2Region > (32 * PixelSize)) Then
  2467.             X1Region = X1Region - (XMoveSelection - XLastMove)
  2468.             X2Region = X2Region - (XMoveSelection - XLastMove)
  2469.         End If
  2470.         
  2471.         ' Prevent Selection from being moved of the top or bottom
  2472.         ' of the editing area
  2473.         '
  2474.         If (Y1Region < 0) Or Y2Region > (32 * PixelSize) Then
  2475.             Y1Region = Y1Region - (YMoveSelection - YLastMove)
  2476.             Y2Region = Y2Region - (YMoveSelection - YLastMove)
  2477.         End If
  2478.     Else
  2479.         ' A selection is being made, so adjust the mouse coordinates
  2480.         ' to the Edge of the pixels so the rectangle is completely
  2481.         ' around the selction.
  2482.         '
  2483.         Adjust_X_and_Y X, Y, X2Region, Y2Region, TO_EDGE
  2484.         ' Make the Selection perfectly square if the Shift key is down
  2485.         '
  2486.         If Shift And SHIFT_MASK Then Make_Region_Square
  2487.     End If
  2488.     ' Draw the new selection recangle
  2489.     '
  2490.     Draw_Selection_Rectangle
  2491. End Sub
  2492. ' When the MousePointer is within the Editing area, the MousePointer
  2493. ' is changed depending on the Tool being used.  This routine is called
  2494. ' from the MouseMove event for the Editing area (Pic_Edit) to change
  2495. ' the MousePointer.
  2496. Private Sub Set_MousePointer(X As Single, Y As Single)
  2497.     If Selecting And Moveable And (X >= X1Region) And (X <= X2Region) And (Y >= Y1Region) And (Y <= Y2Region) Then
  2498.         '
  2499.         ' A selection is in progress and the selection is moveable,
  2500.         ' and the MousePointer is within the the selection, so the
  2501.         ' MousePointer is changed to a SIZE pointer to indacte
  2502.         ' that the Selection can be moved.
  2503.         '
  2504.         Pic_Edit.MousePointer = SIZE
  2505.     ElseIf (CurrentTool = TID_PAINT) Or (CurrentTool = TID_FILL) Then
  2506.         Pic_Edit.MousePointer = UP_ARROW
  2507.     Else
  2508.         Pic_Edit.MousePointer = CROSSHAIR
  2509.     End If
  2510. End Sub
  2511. ' Since some of the tools can only use Solid colors and not Dithered
  2512. ' colors, it is useful to have the option of displayin only the solid
  2513. ' colors within the ColorPalette.  This routine changes the Color
  2514. ' array to contain only Solid color values then redisplays the
  2515. ' ColorPalette.  There are still 3 rows of colors, but each color
  2516. ' cell in the same column are set to the same solid color.
  2517. Private Sub Show_Solid_Colors_Only()
  2518.     ' Set Color array to all solid colors returned from QBColors()
  2519.     '
  2520.     For i = 0 To 15
  2521.         Colors(i) = QBColor(i)
  2522.         Colors(i + 16) = QBColor(i)
  2523.         Colors(i + 32) = QBColor(i)
  2524.     Next
  2525.     ' Redisplay ColorPalettes.
  2526.     '
  2527.     Display_Color_Palette Pic_ColorPalette
  2528.     If ColorPaletteLoaded Then Display_Color_Palette ColorPalette.Pic_ColorPalette
  2529. End Sub
  2530. ' This routine is called in response to an Edit.Undo menu operation.
  2531. ' The Icon displayed in the Undo Icon within the StatusArea is
  2532. ' Copied to the Selected Icon.
  2533. Private Sub UnDo_Edits()
  2534.     ' Terminate any Select or Move opteration
  2535.     '
  2536.     Selecting = False
  2537.     MovingSelection = False
  2538.     ' Get Image and Mask of Icon displayed in Undo Icon in StatusArea
  2539.     '
  2540.     Extract_Image_And_Mask Pic_Undo
  2541.     ' Copy Undo Icons Mask and Image to selected icon
  2542.     '
  2543.     Update_Icon Pic_Icons(CurrentIcon)
  2544.     ' Redisplay entire icon
  2545.     '
  2546.     Magnify_Icon 0, 0, 31, 31
  2547. End Sub
  2548. ' When using either the Circle or Filled Circle tool, this routine is called
  2549. ' to verify that the resulting circle from the current Mouse coordinates is
  2550. ' a valid circle, since in some cases the result would be a vertical or
  2551. ' horizontal line which would generate and "Division by Zero" if not checked
  2552. ' for.  If the Circle is valid, this routine calculates and sets the Global
  2553. ' values of XCenter, YCenter, and Raduis for new Circle.
  2554. Private Function Valid_Circle(X1, Y1, X2, Y2)
  2555.           
  2556.     Xleg = Abs(X2 - X1)
  2557.     If Xleg <> 0 Then
  2558.         Yleg = Abs(Y2 - Y1)
  2559.         Aspect = Abs(Yleg / Xleg)
  2560.         If Xleg > Yleg Then Radius = Xleg / 2 Else Radius = Yleg / 2
  2561.         XCenter = X1 + (X2 - X1) / 2
  2562.         YCenter = Y1 + (Y2 - Y1) / 2
  2563.     End If
  2564.     ' Return value of XLeg at Function value, since if XLeg is non-zero,
  2565.     ' (True) it is a valid circle, and if XLeg is zero (False) it is
  2566.     ' an Invalid circle.
  2567.     '
  2568.     Valid_Circle = Xleg
  2569. End Function
  2570.